From c3c69b160f4c5fd851fd1a49c01f633a56351f5d Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 22 Jul 2021 21:36:15 +0200 Subject: Add smart image conversion --- src/piece.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/piece.rs (limited to 'src/piece.rs') diff --git a/src/piece.rs b/src/piece.rs new file mode 100644 index 0000000..a0cc18e --- /dev/null +++ b/src/piece.rs @@ -0,0 +1,22 @@ +use std::path::PathBuf; +use crate::picture::{Picture, ConversionError}; +use crate::context::Context; + +#[derive(Debug)] +pub struct Piece { + pic: Picture, + scaled_path: PathBuf, + thumb_path: PathBuf, +} + +impl Piece { + pub fn new(ctx: &Context, pic: Picture) -> Result { + let mut conv = pic.convert()?; + let scaled_path = conv.get_size(ctx, ctx.options.size_scaled)?; + let thumb_path = conv.get_size(ctx, ctx.options.size_thumb)?; + + Ok(Piece { + pic, scaled_path, thumb_path, + }) + } +} -- cgit v1.2.3