diff --git a/Cargo.lock b/Cargo.lock index d73b925..a4f97d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -480,7 +480,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "image" version = "0.25.9" -source = "git+https://github.com/image-rs/image.git#aae5fb91a27386801babec31ab07b9a1821e3b03" +source = "git+https://github.com/image-rs/image.git#d29d8453ba65719a4f7e93a8d967ce479b892fc7" dependencies = [ "bytemuck", "byteorder-lite", @@ -499,7 +499,7 @@ dependencies = [ "rgb", "tiff", "zune-core 0.5.1", - "zune-jpeg 0.5.9", + "zune-jpeg 0.5.11", ] [[package]] @@ -568,8 +568,7 @@ checksum = "b454d911ac55068f53495488d8ccd0646eaa540c033a28ee15b07838afafb01f" [[package]] name = "jxl-bitstream" version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480e752277e29eb4054f69546887a9b84656fe78c08f54ba5850ced98a378fe" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "tracing", ] @@ -577,8 +576,7 @@ dependencies = [ [[package]] name = "jxl-coding" version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd972bcd125e776f1eb241ac50e39f956095a1c2770c64736c968f8946bd9a3c" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "jxl-bitstream", "tracing", @@ -587,8 +585,7 @@ dependencies = [ [[package]] name = "jxl-color" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f316b1358c1711755b3ee8e8cb5c4a1dad12e796233088a7a513440782de80b2" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -602,8 +599,7 @@ dependencies = [ [[package]] name = "jxl-frame" version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d967c6fd669c7c01060b5022d8835fa82fd46b06ffc98b549f17600a097c2b3" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -619,8 +615,7 @@ dependencies = [ [[package]] name = "jxl-grid" version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e0ef92d5d60e76bf41098e57e985f523185e08fad54268da448637feca6989" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "tracing", ] @@ -628,8 +623,7 @@ dependencies = [ [[package]] name = "jxl-image" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f752d62577c702a94dbbce4045caf08cb58639e8a4d56464b40ecf33ffe565" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "jxl-bitstream", "jxl-grid", @@ -640,8 +634,7 @@ dependencies = [ [[package]] name = "jxl-jbr" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35d032bcec660647828527ff42c6f5776d2fd44b8357f9f6d9ac6dc07218e46" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "brotli-decompressor", "jxl-bitstream", @@ -658,8 +651,7 @@ dependencies = [ [[package]] name = "jxl-modular" version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da758b2f989aafd9eeb39489fe43d7be5a3a0d2ad61cf1bad705eb6990a6053c" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -672,8 +664,7 @@ dependencies = [ [[package]] name = "jxl-oxide" version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8ecd2678ed70c1eda42b811ccb2e25ab836edeb18e7f1178c1f917ed36b772" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "brotli-decompressor", "bytemuck", @@ -694,8 +685,7 @@ dependencies = [ [[package]] name = "jxl-oxide-common" version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62394c5021b3a9e7e0dbb2d639d555d019090c9946c39f6d3b09d390db4157b" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "jxl-bitstream", ] @@ -703,8 +693,7 @@ dependencies = [ [[package]] name = "jxl-render" version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa0c3100918bd3c41bb0f8ce1f4f1664e48f3032ff8eeab0d6a2cfc3276f462d" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "bytemuck", "jxl-bitstream", @@ -723,8 +712,7 @@ dependencies = [ [[package]] name = "jxl-threadpool" version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f15eb830aa77a7f21148d72e153562a26bfe570139bd4922eab1908dd499d3" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "rayon", "rayon-core", @@ -734,8 +722,7 @@ dependencies = [ [[package]] name = "jxl-vardct" version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce72a18c6d3a47172ab6c479be2bdb56f22066b5d7092663f03b4490820b4511" +source = "git+https://github.com/Shnatsel/jxl-oxide?branch=no-more-rect#3c8e969e56f017de4a22edbeab23063d500064e6" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -1175,9 +1162,9 @@ dependencies = [ [[package]] name = "ravif" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef69c1990ceef18a116855938e74793a5f7496ee907562bd0857b6ac734ab285" +checksum = "e52310197d971b0f5be7fe6b57530dcd27beb35c1b013f29d66c1ad73fbbcc45" dependencies = [ "avif-serialize", "imgref", @@ -1366,18 +1353,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", @@ -1615,9 +1602,9 @@ dependencies = [ [[package]] name = "zune-jpeg" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c86acb70a85b2c16f071f171847d1945e8f44812630463cd14ec83900ad01c" +checksum = "2959ca473aae96a14ecedf501d20b3608d2825ba280d5adb57d651721885b0c2" dependencies = [ "zune-core 0.5.1", ] diff --git a/Cargo.toml b/Cargo.toml index 5dcf1b0..7ec5178 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"} \ No newline at end of file diff --git a/src/operations/crop.rs b/src/operations/crop.rs index c9ee899..bf9302f 100644 --- a/src/operations/crop.rs +++ b/src/operations/crop.rs @@ -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(()) }