diff options
author | Julian T <julian@jtle.dk> | 2021-07-22 21:36:15 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-07-22 21:36:15 +0200 |
commit | c3c69b160f4c5fd851fd1a49c01f633a56351f5d (patch) | |
tree | 55cdca5f052717d1c7f9abab97e864f28dc17534 /src/piece.rs | |
parent | 69bbd4ed3804833b15285cf8637e96e59135f223 (diff) |
Add smart image conversion
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, + }) + } +} |