Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Perf: a full-size raw decode no longer copies its 64 MP image to "fit" it

dev-null-undefined5f2f013c8eb3
diff --git a/crates/engine/src/files.rs b/crates/engine/src/files.rs
index dc79b8b31..feefb21a0 100644
--- a/crates/engine/src/files.rs
+++ b/crates/engine/src/files.rs
@@ -450,7 +450,8 @@ fn load_bytes_now(
stages.push(("highlights", t0.elapsed()));
colour.apply(&mut img);
stages.push(("colour", t0.elapsed()));
- let img = fit(&img, max_edge, max_edge, Filter::Box);
+ // (`fit` copies an image that already fits: 797 MB and 0.3 s for a full-size 64 MP decode)
+ let img = if img.width.max(img.height) > max_edge { fit(&img, max_edge, max_edge, Filter::Box) } else { img };
stages.push(("fit", t0.elapsed()));
let img = img.into_oriented(raw.orientation);
stages.push(("orient", t0.elapsed()));