Skip to content

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

Merge PR #3281: Develop exports from a source at least twice the output size

aiongg6d0902182ccc
diff --cc crates/engine/src/media/session.rs
index 930e800b1,63dfa0b14..1b55c1f23
--- a/crates/engine/src/media/session.rs
+++ b/crates/engine/src/media/session.rs
@@@ -430,8 -429,16 +430,17 @@@ impl crate::Session
space: lightcraft_pipeline::OutputSpace,
depth: lightcraft_pipeline::OutputDepth,
) -> Result<RenderJob, String> {
+ lightcraft_pipeline::check_output_size(max_w, max_h)?;
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 {