Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 23 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ panic = "abort"

[patch.crates-io]
image = {git = "https://github.com/image-rs/image.git"}
# https://github.com/tirr-c/jxl-oxide/pull/488
jxl-oxide = {git = "https://github.com/Shnatsel/jxl-oxide", branch = "no-more-rect"}
13 changes: 12 additions & 1 deletion src/operations/crop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ pub fn crop_on_load(
// https://github.com/image-rs/image/issues/2296
// TODO: change this in `image` because I don't want to emulate this on the client side
// and pretend the problem doesn't exist for anyone else
let cropped = image.crop_imm(geom.xoffset, geom.yoffset, geom.width, geom.height);
let rect = image::math::Rect {
x: geom.xoffset,
y: geom.yoffset,
width: geom.width,
height: geom.height,
};
// crop_in_place exists but doesn't shrink the backing buffer,
// so we have to either allocate the large buffer and keep it around forever
// (lower peak memory usage) or allocate both large and small buffer but drop the large one
// (higher peak memory usage, quickly goes down later).
// This takes the second option, but we might reconsider later if there's compelling evidence.
let cropped = image.crop(rect);
*image = cropped;
Ok(())
}
Expand Down