feat: use stats panel to crop (#8848)

* feat: use stats panel to crop

* fix: test flake

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Ryan Di 2024-12-17 20:15:30 +08:00 committed by GitHub
parent 551bae07a7
commit d99e4a23ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 313 additions and 13 deletions

View file

@ -186,14 +186,14 @@ describe("Crop an image", () => {
// 50 x 50 square
UI.crop(image, "nw", naturalWidth, naturalHeight, [150, 50]);
UI.crop(image, "n", naturalWidth, naturalHeight, [0, -100], true);
expect(image.width).toEqual(image.height);
expect(image.width).toBeCloseTo(image.height);
// image is at the corner, not space to its right to expand, should not be able to resize
expect(image.height).toBeCloseTo(50);
UI.crop(image, "nw", naturalWidth, naturalHeight, [-150, -100], true);
expect(image.width).toEqual(image.height);
expect(image.width).toBeCloseTo(image.height);
// max height should be reached
expect(image.height).toEqual(initialHeight);
expect(image.height).toBeCloseTo(initialHeight);
expect(image.width).toBe(initialHeight);
});
});