diff options
Diffstat (limited to 'src/piece.rs')
-rw-r--r-- | src/piece.rs | 22 |
1 files changed, 22 insertions, 0 deletions
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<Self, ConversionError> { + 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, + }) + } +} |