LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Develop exports from a source at least twice the output size
NetterSilver8a6907877ea1
diff --git a/crates/engine/src/media/session.rs b/crates/engine/src/media/session.rsindex b222739fe..63dfa0b14 100644--- a/crates/engine/src/media/session.rs+++ b/crates/engine/src/media/session.rs@@ -430,6 +430,15 @@ impl crate::Session {depth: lightcraft_pipeline::OutputDepth,) -> Result<RenderJob, String> {let mut job = self.render_job(id, max_w, max_h, false, true).ok_or("no such photo")?;+ // An export develops from a source at least twice its size, so it is resized down with a good filter+ // rather than made from a preview just covering it (for a raw, a binned and box-reduced image)+ let p = self.catalog.photo(id).ok_or("no such photo")?.clone();+ let level = SourceLevel::for_size(source_edge_needed(&p, &job.settings, true, max_w.max(max_h)).saturating_mul(2));+ if level.max_edge() > job.level.max_edge() {+ job.source = self.media.source_ref(&p, level);+ job.key ^= ((job.level as u64) << 60) ^ ((level as u64) << 60);+ job.level = level;+ }// An export renders the full image: never a thumbnail's source developed from a smaller copy of the raw// image that the file keeps (Lightroom's merged DNGs)let reduced = match &job.source {diff --git a/crates/engine/src/media/tests.rs b/crates/engine/src/media/tests.rsindex d36284262..15744f025 100644--- a/crates/engine/src/media/tests.rs+++ b/crates/engine/src/media/tests.rs@@ -517,3 +517,22 @@ fn variant_jobs_have_their_own_keys_and_hit_the_cache() {assert_ne!(pv.key, s.render_job(id, 800, 600, false, true).unwrap().key);assert_eq!(*pv.settings, a);}++/// An export develops from a source at least twice its long edge (a 2000 px export of a 6000 px+/// photo from the original, not the 2560 px preview, which for a raw is binned and box-reduced),+/// while on-screen views keep the cheap preview.+#[test]+fn an_export_develops_from_a_source_twice_its_size() {+ use lightcraft_pipeline::{OutputDepth, OutputSpace};+ let mut s = crate::Session::with_demo();+ let id = s.active().unwrap();+ let p = s.catalog.photo(id).unwrap().clone();+ assert!(p.width.max(p.height) >= 6000, "a camera-sized demo: {}×{}", p.width, p.height);+ let job = s.export_job(id, 2000, 2000, OutputSpace::Srgb, OutputDepth::U8).unwrap();+ assert_eq!(job.level, SourceLevel::Full, "2000 px export");+ for edge in [200, 600, 1280, 1281, 2560] {+ let job = s.export_job(id, edge, edge, OutputSpace::Srgb, OutputDepth::U8).unwrap();+ assert!(job.level.max_edge() >= 2 * edge, "{edge} px export from {:?}", job.level);+ }+ assert_eq!(s.render_job(id, 1600, 1600, false, true).unwrap().level, SourceLevel::Preview, "a view keeps the preview");+}