From fc71331305eefe4a1e86ce39b01eddf0240f0dfa Mon Sep 17 00:00:00 2001 From: Kanyin Cai Date: Sat, 21 Mar 2026 14:28:23 +0100 Subject: [PATCH] fix(02-01): add max(1.0) safety clamp to aspect ratio calculation --- yazi-adapter/src/image.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yazi-adapter/src/image.rs b/yazi-adapter/src/image.rs index 8a67663b..08b05993 100644 --- a/yazi-adapter/src/image.rs +++ b/yazi-adapter/src/image.rs @@ -105,7 +105,10 @@ impl Image { // DynamicImage::resize() behavior. let (w, h) = { let ratio = (w as f64 / img.width() as f64).min(h as f64 / img.height() as f64); - ((img.width() as f64 * ratio).round() as u32, (img.height() as f64 * ratio).round() as u32) + ( + (img.width() as f64 * ratio).round().max(1.0) as u32, + (img.height() as f64 * ratio).round().max(1.0) as u32, + ) }; let img = match img.pixel_type() {