From bb3af8527538b9b23080bd9450a41192942a86b6 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Wed, 13 Nov 2024 15:39:05 -0600 Subject: [PATCH] Perf regression: typoed image filter type Signed-off-by: eternal-flame-AD --- src/post_process/image_processing.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/post_process/image_processing.rs b/src/post_process/image_processing.rs index 2b8e5cd..c570bef 100644 --- a/src/post_process/image_processing.rs +++ b/src/post_process/image_processing.rs @@ -141,13 +141,18 @@ fn process_static_image_impl(mut image: DynamicImage, opt: &ImageOptions) -> Dyn return image.resize_exact(96, 96, image::imageops::FilterType::Nearest); } + let mut use_bilinear = true; + if opt.emoji == Some(true) { + use_bilinear = false; out_dim = clamp_height(out_dim, 128); } else if opt.avatar == Some(true) { + use_bilinear = false; out_dim = clamp_height(out_dim, 320); } if opt.preview == Some(true) { + use_bilinear = false; out_dim = clamp_dimensions(out_dim, 200, 200); } @@ -156,7 +161,15 @@ fn process_static_image_impl(mut image: DynamicImage, opt: &ImageOptions) -> Dyn } if out_dim != image.dimensions() { - image = image.resize_exact(out_dim.0, out_dim.1, image::imageops::FilterType::Lanczos3); + image = image.resize_exact( + out_dim.0, + out_dim.1, + if use_bilinear { + image::imageops::FilterType::Triangle + } else { + image::imageops::FilterType::Nearest + }, + ); } image