From 3fba256405c4aae9f121a07ddaa29cc10b825fc9 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Mon, 10 Feb 2025 07:39:04 -0300 Subject: Don't crash on image with zero DPI (#5835) --- crates/typst-layout/src/image.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'crates/typst-layout/src/image.rs') diff --git a/crates/typst-layout/src/image.rs b/crates/typst-layout/src/image.rs index d963ea50..3e5b7d8b 100644 --- a/crates/typst-layout/src/image.rs +++ b/crates/typst-layout/src/image.rs @@ -95,6 +95,8 @@ pub fn layout_image( } else { // If neither is forced, take the natural image size at the image's // DPI bounded by the available space. + // + // Division by DPI is fine since it's guaranteed to be positive. let dpi = image.dpi().unwrap_or(Image::DEFAULT_DPI); let natural = Axes::new(pxw, pxh).map(|v| Abs::inches(v / dpi)); Size::new( -- cgit v1.2.3