From 86e39cc9c053a8746ee26cc6f3199b3d8c410ea5 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 24 Oct 2026 10:04:32 +0700 Subject: [PATCH] #703: a Cmd/Ctrl-resize crop whose coefficients aren't finite leaves the image fill as it is --- crates/engine/src/tools.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tools.rs b/crates/engine/src/tools.rs index ca078eb56..493df125b 100644 --- a/crates/engine/src/tools.rs +++ b/crates/engine/src/tools.rs @@ -1711,7 +1711,12 @@ impl Session { let s = if img.scale_mode == ImageScaleMode::Fit { (w / rw).min(h / rh) } else { (w / rw).max(h / rh) }; [w / (rw * s), 0.0, 0.0, h / (rh * s), (rw * s - w) / (2.0 * rw * s), (rh * s - h) / (2.0 * rh * s)] }; - img.crop = Some((Affine::new(crop) * to_old).as_coeffs()); + // A degenerate (zero-scale) layer has no inverse: its image keeps its placement. + let crop = (Affine::new(crop) * to_old).as_coeffs(); + if !crop.iter().all(|c| c.is_finite()) { + continue; + } + img.crop = Some(crop); img.scale_mode = ImageScaleMode::Crop; } doc.get_mut(*id)?.fills = fills;