From 70a1f99b313052af61c9c2fc1737679d290bb2ee Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:26:00 +0100 Subject: [PATCH] Image Size test: expect the selection dropped, check Crop's resample keeps it image_size_keeps_canvas_edges_opaque asserted the old behaviour (a scaled full selection after Image Size). Image Size now drops it (#13856); the corner check moves to resample_doc, which the Crop tool's W x H x Resolution mode still uses. --- crates/engine/src/cmd/image_cmds/tests.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/image_cmds/tests.rs b/crates/engine/src/cmd/image_cmds/tests.rs index 4d0478eccbe..5acec8b8ba5 100644 --- a/crates/engine/src/cmd/image_cmds/tests.rs +++ b/crates/engine/src/cmd/image_cmds/tests.rs @@ -205,8 +205,20 @@ fn image_size_keeps_canvas_edges_opaque() { let mut s = Session::new(); s.execute("file.new", json!({"width": 30, "height": 20, "depth": depth, "background": "#336699"})).unwrap(); s.execute("select.all", json!({})).unwrap(); + // The Crop tool's W x H x Resolution mode still resamples the selection with the + // pixels: a full selection keeps reaching the canvas edges. + let mut cropped = (*doc(&s)).clone(); + let ch = (20 * w + 15) / 30; + resample_doc(&mut cropped, "test", w, ch, Resample::Bicubic).unwrap(); + let sel = cropped.selection.as_ref().unwrap(); + let (x1, y1) = (cropped.size.width as i32 - 1, cropped.size.height as i32 - 1); + for (x, y) in [(0, 0), (x1, 0), (0, y1), (x1, y1)] { + assert!(sel.pixel(x, y)[0] > 0.99, "{depth} {resample}: selection at ({x},{y})"); + } s.execute("image.imageSize", json!({"width": w, "resample": resample})).unwrap(); let d = doc(&s); + // Image Size drops the selection when it resamples (#13856). + assert!(d.selection.is_none(), "{depth} {resample}: Image Size dropped the selection"); let flat = photocraft_compose::flatten(d); let (w, h) = (flat.rect.width() as usize, flat.rect.height() as usize); let mid = flat.px[(h / 2) * w + w / 2]; @@ -215,11 +227,6 @@ fn image_size_keeps_canvas_edges_opaque() { let off = p.iter().zip(mid).map(|(a, b)| (a - b).abs()).fold(0.0f32, f32::max); assert!(off < 0.01, "{depth} {resample} {w}: {p:?} vs {mid:?}"); } - let sel = d.selection.as_ref().unwrap(); - let (x1, y1) = (d.size.width as i32 - 1, d.size.height as i32 - 1); - for (x, y) in [(0, 0), (x1, 0), (0, y1), (x1, y1)] { - assert!(sel.pixel(x, y)[0] > 0.99, "{depth} {resample}: selection at ({x},{y})"); - } } } }