diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-11-25 16:56:29 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-11-25 16:56:29 +0100 |
| commit | 11e44516fae84f907ea992311fcfdc3636101f14 (patch) | |
| tree | ff9b6a04c3accd5c0f75f1ceb60e578c389a2606 /src/library/graphics.rs | |
| parent | 761931405c68efe0a35d96524df797dda7155723 (diff) | |
Merge some modules 🥞
Diffstat (limited to 'src/library/graphics.rs')
| -rw-r--r-- | src/library/graphics.rs | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/library/graphics.rs b/src/library/graphics.rs deleted file mode 100644 index 779d78b5..00000000 --- a/src/library/graphics.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::fs::File; -use std::io::BufReader; - -use image::io::Reader; - -use crate::layout::Image; -use crate::prelude::*; - -/// `image`: Include an image. -/// -/// # Positional arguments -/// - The path to the image (string) -pub fn image(mut args: Args, ctx: &mut EvalContext) -> Value { - let path = args.need::<_, Spanned<String>>(ctx, 0, "path"); - let width = args.get::<_, Linear>(ctx, "width"); - let height = args.get::<_, Linear>(ctx, "height"); - - if let Some(path) = path { - if let Ok(file) = File::open(path.v) { - match Reader::new(BufReader::new(file)) - .with_guessed_format() - .map_err(|err| err.into()) - .and_then(|reader| reader.decode()) - .map(|img| img.into_rgba8()) - { - Ok(buf) => { - ctx.push(Image { - buf, - width, - height, - align: ctx.state.align, - }); - } - Err(err) => ctx.diag(error!(path.span, "invalid image: {}", err)), - } - } else { - ctx.diag(error!(path.span, "failed to open image file")); - } - } - - Value::None -} |
