diff --git a/bin/src/commands/photoshoot/mod.rs b/bin/src/commands/photoshoot/mod.rs index 2d3082b8..504bd133 100644 --- a/bin/src/commands/photoshoot/mod.rs +++ b/bin/src/commands/photoshoot/mod.rs @@ -12,6 +12,7 @@ use hemtt_common::{ config::ProjectConfig, }; use hemtt_config::{Class, Config, Property, Value}; +use image::codecs::jpeg::JpegEncoder; use crate::{ context::{Context, PreservePrevious}, @@ -261,7 +262,15 @@ impl Action for Photoshoot { .to_string(), target.display() ); - image.save(target).expect("save"); + let target = std::fs::File::create(target).expect("create"); + JpegEncoder::new_with_quality(target, 90) + .encode( + &image, + image.width(), + image.height(), + image::ExtendedColorType::Rgb8, + ) + .expect("encode"); } vec![self.next_message()] } diff --git a/bin/src/utils/photoshoot.rs b/bin/src/utils/photoshoot.rs index d57e144d..e70202e2 100644 --- a/bin/src/utils/photoshoot.rs +++ b/bin/src/utils/photoshoot.rs @@ -19,7 +19,7 @@ impl Photoshoot { &new.to_image(), 512, 512, - image::imageops::FilterType::Nearest, + image::imageops::FilterType::Lanczos3, ); for pixel in new.pixels_mut() { if is_background(*pixel) { @@ -40,7 +40,8 @@ impl Photoshoot { /// [`Error::Image`] if the image could not be loaded pub fn preview(path: &Path) -> Result, Vec>, Error> { let new = image::open(path)?.into_rgb8(); - let mut new = image::imageops::resize(&new, 455, 256, image::imageops::FilterType::Nearest); + let mut new = + image::imageops::resize(&new, 455, 256, image::imageops::FilterType::Lanczos3); for pixel in new.pixels_mut() { Self::gamma_rgb(pixel); }