fix(splash): check for zero-sized images

This commit is contained in:
2025-10-24 19:06:58 -07:00
parent 0b0b4dc19d
commit d39fbae168

View File

@@ -52,6 +52,11 @@ fn fit_to_frame(image: &DynamicImage, frame: Rect) -> Rect {
height: image.height(), 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. // Calculate the ratio of the image dimensions.
let input_ratio = input.width as f32 / input.height as f32; 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, 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 { if input_ratio < frame_ratio {
output.width = (frame.height as f32 * input_ratio).floor() as u32; output.width = (frame.height as f32 * input_ratio).floor() as u32;
output.height = frame.height; output.height = frame.height;