Perf regression: typoed image filter type

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-13 15:39:05 -06:00
parent a3eb9f7fb1
commit bb3af85275
No known key found for this signature in database

View file

@ -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); return image.resize_exact(96, 96, image::imageops::FilterType::Nearest);
} }
let mut use_bilinear = true;
if opt.emoji == Some(true) { if opt.emoji == Some(true) {
use_bilinear = false;
out_dim = clamp_height(out_dim, 128); out_dim = clamp_height(out_dim, 128);
} else if opt.avatar == Some(true) { } else if opt.avatar == Some(true) {
use_bilinear = false;
out_dim = clamp_height(out_dim, 320); out_dim = clamp_height(out_dim, 320);
} }
if opt.preview == Some(true) { if opt.preview == Some(true) {
use_bilinear = false;
out_dim = clamp_dimensions(out_dim, 200, 200); 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() { 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 image