From e1f97e915f5ff67b08ff56ad9fad091720b75554 Mon Sep 17 00:00:00 2001 From: Stephen <webmaster@scd31.com> Date: Sun, 23 Apr 2023 21:22:39 -0300 Subject: [PATCH] even better image resizing logic --- src/img.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/img.rs b/src/img.rs index bada3c3..61ceb08 100644 --- a/src/img.rs +++ b/src/img.rs @@ -22,11 +22,15 @@ impl ImgInfo { // resize so that the larger dimension is 512 let (mut w, mut h) = resize_dimensions(img.width(), img.height(), IMG_DIM, IMG_DIM, false); + let img = img.resize_exact(w, h, FilterType::Triangle); + // make both dimensions divisible by 16 (SSDV requirement) - w -= w % 16; - h -= h % 16; + let wdiff = w % 16; + let hdiff = h % 16; + w -= wdiff; + h -= hdiff; - let img = img.resize_exact(w, h, FilterType::Triangle); + let img = img.crop_imm(wdiff / 2, hdiff / 2, w, h); let mut bytes = vec![]; -- GitLab