From d39fbae168d0b29c22d544182b4e460b2bf416f9 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Fri, 24 Oct 2025 19:06:58 -0700 Subject: [PATCH] fix(splash): check for zero-sized images --- src/actions/splash.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/actions/splash.rs b/src/actions/splash.rs index a51903b..6e1ca91 100644 --- a/src/actions/splash.rs +++ b/src/actions/splash.rs @@ -52,6 +52,11 @@ fn fit_to_frame(image: &DynamicImage, frame: Rect) -> Rect { height: image.height(), }; + // Handle the case where the image is zero-sized. + if input.height == 0 || input.width == 0 { + return input; + } + // Calculate the ratio of the image dimensions. let input_ratio = input.width as f32 / input.height as f32; @@ -66,6 +71,11 @@ fn fit_to_frame(image: &DynamicImage, frame: Rect) -> Rect { height: frame.height, }; + // Handle the case where the output is zero-sized. + if output.height == 0 || output.width == 0 { + return output; + } + if input_ratio < frame_ratio { output.width = (frame.height as f32 * input_ratio).floor() as u32; output.height = frame.height;