use image::imageops::FilterType; use image::{imageops, GenericImage, Pixel}; use crate::TypedOutputFormat; pub fn rescale<T: GenericImage>(image: &T, factor: f32) -> anyhow::Result<TypedOutputFormat<T>> where T::Pixel: 'static, <T::Pixel as Pixel>::Subpixel: 'static, { let nwidth = (image.width() as f32 * factor) as u32; let nheight = (image.height() as f32 * factor) as u32; Ok(imageops::resize( image, nwidth, nheight, FilterType::Nearest, )) }