From a00d0053cac48a6f802e79d752d6d86778582882 Mon Sep 17 00:00:00 2001 From: QuirkyTurtle94 <19783542+QuirkyTurtle94@users.noreply.github.com> Date: Mon, 12 Oct 2026 20:32:40 +0100 Subject: [PATCH 1/3] CI.1: Make filesystem and dialog tests portable on macOS Locate the Unix test child through PATH, preserve physical-file fault injection across case aliases, handle APFS filename restrictions, and account for the Apple Photos export row. Reuse the test-only fixes from local commit 3fd5d829. Co-authored-by: Codex --- crates/catalog/src/tests_lock.rs | 3 +-- .../src/sidecar/tests_repair_companions.rs | 7 ++++--- .../src/sidecar/tests_repair_provenance.rs | 2 +- .../engine/src/sidecar/tests_repair_saves.rs | 11 +++++++--- crates/engine/src/tests_lightroom_folder.rs | 20 ++++++++++++++----- crates/ui-egui/src/tests_dialog_fit.rs | 5 +++-- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/crates/catalog/src/tests_lock.rs b/crates/catalog/src/tests_lock.rs index 1f5dcec24e5..d464d5c25a1 100644 --- a/crates/catalog/src/tests_lock.rs +++ b/crates/catalog/src/tests_lock.rs @@ -140,8 +140,7 @@ fn dropping_the_lock_frees_the_library_while_another_thread_spawns_processes() { std::thread::spawn(move || { let mut spawned = 0usize; while !stop.load(Ordering::Relaxed) { - if let Ok(mut c) = - std::process::Command::new("/bin/true").stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null()).spawn() + if let Ok(mut c) = std::process::Command::new("true").stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null()).spawn() { let _ = c.wait(); spawned += 1; diff --git a/crates/engine/src/sidecar/tests_repair_companions.rs b/crates/engine/src/sidecar/tests_repair_companions.rs index cefec46e8df..6f4927af519 100644 --- a/crates/engine/src/sidecar/tests_repair_companions.rs +++ b/crates/engine/src/sidecar/tests_repair_companions.rs @@ -16,7 +16,7 @@ impl MoveFs for Faults { RealFs.same_file(a, b) } fn rename_no_replace(&self, a: &Path, b: &Path) -> std::io::Result<()> { - if self.0.iter().any(|p| p == a) { + if self.0.iter().any(|p| p == a || RealFs.same_file(p, a)) { Err(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "injected partial move")) } else { RealFs.rename_no_replace(a, b) @@ -261,8 +261,9 @@ fn queued_stem_retry_preserves_shared_packet_after_batch_rollback() { assert!(!second_packet.exists()); let pending = queues(&s); assert_eq!(pending.len(), 1); - assert_eq!(pending[0].from, shared); - assert_eq!(pending[0].to, second_packet); + // Case-insensitive filesystems may retain the uppercase alias of the shared packet. + assert!(RealFs.same_file(&pending[0].from, &shared), "repair retains the same physical shared packet"); + assert_eq!(pending[0].to, second_packet.with_extension(pending[0].from.extension().unwrap())); let catalog_before = s.catalog.to_snapshot(); let history_before = (s.undo.len(), s.redo.len(), s.commits()); diff --git a/crates/engine/src/sidecar/tests_repair_provenance.rs b/crates/engine/src/sidecar/tests_repair_provenance.rs index 63ff420024f..ea4060aac13 100644 --- a/crates/engine/src/sidecar/tests_repair_provenance.rs +++ b/crates/engine/src/sidecar/tests_repair_provenance.rs @@ -16,7 +16,7 @@ impl MoveFs for Faults { RealFs.same_file(a, b) } fn rename_no_replace(&self, a: &Path, b: &Path) -> std::io::Result<()> { - if self.0.iter().any(|p| p == a) { + if self.0.iter().any(|p| p == a || RealFs.same_file(p, a)) { Err(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "injected provenance partial move")) } else { RealFs.rename_no_replace(a, b) diff --git a/crates/engine/src/sidecar/tests_repair_saves.rs b/crates/engine/src/sidecar/tests_repair_saves.rs index 6f9fa4aa412..82ad454d9ef 100644 --- a/crates/engine/src/sidecar/tests_repair_saves.rs +++ b/crates/engine/src/sidecar/tests_repair_saves.rs @@ -19,14 +19,14 @@ impl MoveFs for PartialRename { RealFs.same_file(a, b) } fn rename_no_replace(&self, a: &Path, b: &Path) -> std::io::Result<()> { - if a == self.sidecar || a == self.photo { + if a == self.sidecar || a == self.photo || RealFs.same_file(a, &self.sidecar) || RealFs.same_file(a, &self.photo) { Err(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "transient rename fault")) } else { RealFs.rename_no_replace(a, b) } } fn copy_no_replace(&self, a: &Path, b: &Path) -> std::io::Result<()> { - if a == self.sidecar { + if a == self.sidecar || RealFs.same_file(a, &self.sidecar) { Err(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "transient copy fault")) } else { RealFs.copy_no_replace(a, b) @@ -151,7 +151,12 @@ fn autowrite_repairs_partial_rename_before_merging_foreign_xmp_across_library_sw assert_eq!(parsed.title.as_deref(), Some("Final title")); assert!(parsed.keywords.as_ref().unwrap().contains(&"café".to_string())); if upper { - assert!(!preferred.exists(), "merge uses the repaired uppercase packet"); + // On a case-insensitive filesystem exists() also finds the uppercase + // packet. Check its directory entry to detect an extra lowercase file. + let lower_entry = std::fs::read_dir(preferred.parent().unwrap()) + .unwrap() + .any(|entry| entry.unwrap().file_name() == preferred.file_name().unwrap()); + assert!(!lower_entry, "merge uses the repaired uppercase packet"); } for (step, title) in [("edit.undo", "Fresh title"), ("edit.redo", "Final title")] { s.execute(step, &json!({})).unwrap(); diff --git a/crates/engine/src/tests_lightroom_folder.rs b/crates/engine/src/tests_lightroom_folder.rs index cdf9905c43d..9719c69142e 100644 --- a/crates/engine/src/tests_lightroom_folder.rs +++ b/crates/engine/src/tests_lightroom_folder.rs @@ -156,12 +156,22 @@ fn odd_folders_never_fail_the_check() { { use std::os::unix::ffi::OsStrExt; let bad = root.join(std::ffi::OsStr::from_bytes(b"caf\xe9 Previews.lrdata")); - std::fs::create_dir_all(&bad).unwrap(); - std::fs::write(root.join("Cat.lrcat"), b"x").unwrap(); - assert_eq!(lightroom_catalog_at(&bad), Some(LightroomPlace { catalog: Some(root.join("Cat.lrcat")) }), "non-UTF-8 name"); - let lr = root.join(std::ffi::OsStr::from_bytes(b"\xff\xfe")); + let created = std::fs::create_dir_all(&bad); + // APFS rejects non-UTF-8 names with EILSEQ. Test its unavailable-path result, + // and still run the ordinary catalog/symlink checks with a representable directory. + let unrepresentable = cfg!(target_os = "macos") && created.as_ref().is_err_and(|e| e.raw_os_error() == Some(92)); + if unrepresentable { + assert_eq!(lightroom_catalog_at(&bad), Some(LightroomPlace { catalog: None })); + } else { + created.unwrap(); + std::fs::write(root.join("Cat.lrcat"), b"x").unwrap(); + assert_eq!(lightroom_catalog_at(&bad), Some(LightroomPlace { catalog: Some(root.join("Cat.lrcat")) }), "non-UTF-8 name"); + } + let lr = if unrepresentable { root.join("catalog") } else { root.join(std::ffi::OsStr::from_bytes(b"\xff\xfe")) }; std::fs::create_dir_all(&lr).unwrap(); - std::fs::write(lr.join(std::ffi::OsStr::from_bytes(b"\xff.lrcat")), b"x").unwrap(); + if !unrepresentable { + std::fs::write(lr.join(std::ffi::OsStr::from_bytes(b"\xff.lrcat")), b"x").unwrap(); + } std::fs::write(lr.join("b.lrcat"), b"x").unwrap(); assert_eq!(lightroom_catalog_at(&lr), Some(LightroomPlace { catalog: Some(lr.join("b.lrcat")) }), "non-UTF-8 entries skipped"); // a symlink to a catalog folder is one too; a dangling one is not diff --git a/crates/ui-egui/src/tests_dialog_fit.rs b/crates/ui-egui/src/tests_dialog_fit.rs index 895a1d86457..b2b18d79ce0 100644 --- a/crates/ui-egui/src/tests_dialog_fit.rs +++ b/crates/ui-egui/src/tests_dialog_fit.rs @@ -94,8 +94,9 @@ fn export_dialog_is_unchanged_in_a_tall_window() { assert_fits(&h, "Export at 1600×1000"); let dialog = rect(&h, "dialog:window"); // (846 tall as before #781: the whole dialog, nothing scrolled away; 615 wide since the - // format row gained JPEG XL, #780) - assert!((dialog.height() - 846.0).abs() <= 1.0, "{dialog:?}"); + // format row gained JPEG XL, #780). The macOS-only Apple Photos checkbox adds one row. + let expected_height = 846.0 + if cfg!(target_os = "macos") { 30.0 } else { 0.0 }; + assert!((dialog.height() - expected_height).abs() <= 1.0, "{dialog:?}"); assert!((dialog.width() - 615.2).abs() <= 1.0, "{dialog:?}"); } From 8ced7822150a93cccfe7fef0e4449131684d1e21 Mon Sep 17 00:00:00 2001 From: QuirkyTurtle94 <19783542+QuirkyTurtle94@users.noreply.github.com> Date: Mon, 12 Oct 2026 20:33:01 +0100 Subject: [PATCH 2/3] #1310: Show accepted RAW starting-colour source in Profile panels Carry accepted colour and tone provenance from decoding to the selected photo in native and browser views. Distinguish validated local and built-in profiles, per-photo and partial fits, file matrices, spectral colour, and neutral fallback without changing pixels or cache versions. Co-authored-by: Codex --- apps/lightcraft-web/src/wire.rs | 30 +++++++ apps/lightcraft-web/src/workers.rs | 18 +++- crates/engine/src/camera_preview.rs | 99 ++++++++++++++++----- crates/engine/src/camera_profiles.rs | 52 +++++++++-- crates/engine/src/files.rs | 4 +- crates/engine/src/media.rs | 67 +++++++++++++- crates/pipeline/src/lib.rs | 22 +++++ crates/ui-egui/locales/de-formats.json | 4 +- crates/ui-egui/locales/es-formats.json | 4 +- crates/ui-egui/locales/fr-formats.json | 4 +- crates/ui-egui/locales/ja-formats.json | 4 +- crates/ui-egui/locales/pt-br-formats.json | 4 +- crates/ui-egui/locales/ru-formats.json | 4 +- crates/ui-egui/locales/uk-formats.json | 4 +- crates/ui-egui/locales/zh-hans-formats.json | 4 +- crates/ui-egui/locales/zh-hant-formats.json | 4 +- crates/ui-egui/src/panels/edit.rs | 1 + crates/ui-egui/src/panels/profiles.rs | 98 ++++++++++++++++++++ docs/camera-preview-colour.md | 17 ++++ docs/gaps.md | 5 +- docs/parity-checklist.md | 5 +- 21 files changed, 409 insertions(+), 45 deletions(-) diff --git a/apps/lightcraft-web/src/wire.rs b/apps/lightcraft-web/src/wire.rs index e231c47c5a6..385e72a5e6d 100644 --- a/apps/lightcraft-web/src/wire.rs +++ b/apps/lightcraft-web/src/wire.rs @@ -168,6 +168,11 @@ impl WorkerCore { } } + /// Provenance of the original most recently decoded for this job, without transferring pixels. + pub fn colour_source(&self, job: &WireJob) -> Option { + self.sources.peek(&job.source_key()).and_then(|src| src.info.as_ref()).and_then(|info| info.colour_source.clone()) + } + /// Render `job`; `original` holds the file's bytes when [`WorkerCore::needs_original`] asked. pub fn render(&mut self, job: &WireJob, original: Option<&[u8]>) -> Result { let key = job.source_key(); @@ -367,6 +372,31 @@ mod tests { use lightcraft_engine::Session; // Issue #229: a failed worker attempt must not shift the positions of the workers after it + #[test] + fn worker_provenance_follows_the_decoded_source_identity() { + use lightcraft_engine::pipeline::{ColourBasis, ColourSource}; + let mut session = lightcraft_engine::Session::with_demo(); + let id = session.active().unwrap(); + let job = session.thumb_job(id, 32).unwrap(); + let mut wire = WireJob::from_job(&job, false, "Thumb"); + let mut core = WorkerCore::default(); + assert!(core.colour_source(&wire).is_none()); + let source = ColourSource { + basis: ColourBasis::CameraProfile { model: "Test Camera".into(), local: false }, + monochrome_tone: true, + dro_tone_removed: true, + }; + let decoded = DecodedSource::new( + Arc::new(lightcraft_raster::Rgb32f::new(4, 4)), + Some(SourceInfo { colour_source: Some(source.clone()), ..Default::default() }), + ); + core.sources.insert(wire.source_key(), decoded, 1024); + let transported = serde_json::to_string(&core.colour_source(&wire)).unwrap(); + assert_eq!(serde_json::from_str::>(&transported).unwrap(), Some(source)); + wire.source_identity = Some("changed original".into()); + assert!(core.colour_source(&wire).is_none()); + } + #[test] fn a_failed_worker_attempt_leaves_no_gap_in_the_slots() { let mut slots = WorkerSlots::default(); diff --git a/apps/lightcraft-web/src/workers.rs b/apps/lightcraft-web/src/workers.rs index f1523c37749..d45ee3b04d7 100644 --- a/apps/lightcraft-web/src/workers.rs +++ b/apps/lightcraft-web/src/workers.rs @@ -111,6 +111,10 @@ async fn handle(scope: &web_sys::DedicatedWorkerGlobalScope, backend: Option None, }; let rendered = CORE.with(|c| c.borrow_mut().render(&job, original.as_deref()))?; + if let Some(source) = CORE.with(|c| c.borrow().colour_source(&job)) { + let text = serde_json::to_string(&source).map_err(|e| e.to_string())?; + set(&out, "colourSource", &text.into()); + } let mut stored = 0; if let (Some(b), Some(key)) = (&backend, job.thumb_key()) && let Some(jpeg) = lightcraft_preview::encode_jpeg(&rendered.image) @@ -151,6 +155,7 @@ async fn handle(scope: &web_sys::DedicatedWorkerGlobalScope, backend: Option, disk_key: Option, namespace: u64, request_id: u64, @@ -290,13 +295,14 @@ impl Workers { if let Some(b) = w.busy.take() { let r = RenderResult { request_id: b.request_id, - source_key: None, + source_key: b.source_key, photo: b.photo, level: b.level, key: b.key, rendered: Err(msg), gpu_fallback: None, loaded: None, + colour_source: None, quick: None, display: None, }; @@ -369,18 +375,24 @@ impl Workers { let _ = backend.remove(&thumb_storage_key(&key)).await; }); } + let colour_source = if rendered.is_ok() && b.namespace == g.index.namespace() { + get(&data, "colourSource").as_string().and_then(|text| serde_json::from_str(&text).ok()) + } else { + None + }; g.remote_done += 1; g.done.push(( b.slot, RenderResult { request_id: b.request_id, - source_key: None, + source_key: b.source_key, photo: b.photo, level: b.level, key: b.key, rendered, gpu_fallback: None, loaded: None, + colour_source, quick: None, display: None, }, @@ -435,6 +447,7 @@ impl RenderOffload for Workers { rendered: Ok(Rendered { image, histogram, deep: None }), gpu_fallback: None, loaded: None, + colour_source: None, quick: None, display: None, }; @@ -483,6 +496,7 @@ impl RenderOffload for Workers { return Some(job); } w.busy = Some(Busy { + source_key: job.source_key, disk_key, namespace, request_id: job.request_id, diff --git a/crates/engine/src/camera_preview.rs b/crates/engine/src/camera_preview.rs index 858f3b4cf56..c06f7352226 100644 --- a/crates/engine/src/camera_preview.rs +++ b/crates/engine/src/camera_preview.rs @@ -6,6 +6,7 @@ //! (applied like a DNG `ProfileHueSatMap`) corrects that when it also improves the held-out pixels. use lightcraft_color::{D50, D65, Mat3, PROPHOTO, REC2020, Xy, bradford, luminance_2020}; use lightcraft_pipeline::tone::{CameraTone, ToneMap}; +use lightcraft_pipeline::{ColourBasis, ColourSource}; use lightcraft_raster::{ Rgb32f, resample::{Filter, fit, resize}, @@ -29,12 +30,20 @@ pub const LOOK_VERSION: u32 = 4; #[derive(Clone, Debug)] pub(crate) struct CameraLook { + provenance: LookProvenance, pub matrix: Mat3, pub tone: CameraTone, /// Hue/saturation correction after `matrix`, in linear ProPhoto RGB (DNG `ProfileHueSatMap`). pub hue_sat: Option, } +#[derive(Clone, Copy, Debug, Default)] +struct LookProvenance { + profile: bool, + partial: bool, + dro_tone_removed: bool, +} + /// Long edge of the sensor/JPEG proxy a single photo's look is fitted on (the acceptance gates /// below were set at this size). const PROXY: usize = 96; @@ -69,7 +78,7 @@ pub(crate) fn file_local_look(format: RawFormat) -> bool { /// white (a monochrome picture style) has no colour to fit, but still gives its tone curve: with the camera profile's /// colour in [`fit_preview`], else on top of the spectral matrices or the fallback ([`monochrome_look`]). Returns the /// as-shot white, the camera transform at it and the fitted look. -pub(crate) fn starting_colour(raw: &mut RawImage, bytes: &[u8]) -> (Xy, CameraTransform, Option) { +pub(crate) fn starting_colour(raw: &mut RawImage, bytes: &[u8]) -> (Xy, CameraTransform, Option, ColourSource) { starting_colour_with(raw, |raw, t| fit_preview(raw, bytes, t), |raw, t| monochrome_look(raw, bytes, t)) } @@ -79,18 +88,31 @@ fn starting_colour_with( raw: &mut RawImage, fit: impl FnOnce(&RawImage, &CameraTransform) -> (Option, bool), monochrome: impl FnOnce(&RawImage, &CameraTransform) -> Option, -) -> (Xy, CameraTransform, Option) { +) -> (Xy, CameraTransform, Option, ColourSource) { let start = |raw: &RawImage| { let xy = lightcraft_raw::color::as_shot_white_xy(raw); (xy, lightcraft_raw::color::camera_transform(raw, xy)) }; let (xy, t) = start(raw); if !t.matrix_is_fallback { - return (xy, t, None); + return (xy, t, None, ColourSource { basis: ColourBasis::FileMatrices, monochrome_tone: false, dro_tone_removed: false }); } let (look, black_and_white) = fit(raw, &t); if let Some(look) = look { - return (xy, t, Some(look)); + let basis = if look.provenance.profile { + raw.metadata + .model + .as_deref() + .and_then(crate::camera_profiles::resolved) + .map(|p| ColourBasis::CameraProfile { model: p.profile.model.clone(), local: p.local }) + .unwrap_or(ColourBasis::CameraJpeg) + } else if look.provenance.partial { + ColourBasis::PartialCameraJpeg + } else { + ColourBasis::CameraJpeg + }; + let source = ColourSource { basis, monochrome_tone: black_and_white, dro_tone_removed: look.provenance.dro_tone_removed }; + return (xy, t, Some(look), source); } let (xy, t) = match raw.metadata.model.as_deref().and_then(|model| lightcraft_raw::spectral::find(raw.metadata.make.as_deref(), model)) { Some(camera) => { @@ -104,7 +126,12 @@ fn starting_colour_with( }; // only a black-and-white JPEG: a colour one that gave no look pays nothing more let look = if black_and_white { monochrome(raw, &t) } else { None }; - (xy, t, look) + let source = ColourSource { + basis: if t.matrix_is_fallback { ColourBasis::Neutral } else { ColourBasis::Spectral }, + monochrome_tone: look.is_some(), + dro_tone_removed: look.as_ref().is_some_and(|look| look.provenance.dro_tone_removed), + }; + (xy, t, look, source) } /// The look fitted to the file's camera JPEG, and whether that JPEG is black and white ([`monochrome`]). @@ -252,7 +279,7 @@ fn with_dro_off_tone(look: CameraLook) -> CameraLook { if !at_most(&tone, &look.tone) { return look; } - CameraLook { tone, ..look } + CameraLook { tone, provenance: LookProvenance { dro_tone_removed: tone != look.tone, ..look.provenance }, ..look } } /// Whether curve `a` is nowhere brighter than `b` over the scene luminances the finish stage's tone @@ -688,6 +715,7 @@ fn fit_pairs_on( // A known colour model needs enough signal for tone fitting, not a scene rich enough to // learn a new colour matrix. Still reject monochrome references. let (pairs, bright) = collect_pairs(sensor, reference, if colour.is_some() { 0.005 } else { 0.05 }, edge_limit)?; + let uses_profile = colour.is_some(); let candidates = match colour { Some(given) => vec![given], None => { @@ -708,7 +736,8 @@ fn fit_pairs_on( let tone_pairs: Vec<_> = pairs.iter().enumerate().filter(|(i, _)| i % 3 != 0).map(|(_, (x, y))| (luma(colour(*x).map(|v| v.max(0.0))), luma(*y))).collect(); let Some(curve) = tone_fit.fit(tone_pairs) else { continue }; - let mut look = CameraLook { matrix, tone: curve, hue_sat: hue_sat.clone() }; + let mut look = + CameraLook { matrix, tone: curve, hue_sat: hue_sat.clone(), provenance: LookProvenance { profile: uses_profile, ..Default::default() } }; if let Some(tone) = fit_chroma(&bright, &look) { look.tone = tone; } @@ -851,7 +880,8 @@ fn fit_partial_on(sensor: &Rgb32f, reference: &Rgb32f, edge_limit: Option) }; let tone_pairs: Vec<_> = pairs.iter().enumerate().filter(|(i, _)| i % 3 != 0).map(|(_, (x, y))| (luma(matrix.apply(*x).map(|v| v.max(0.0))), luma(*y))).collect(); - let mut look = CameraLook { matrix, tone: fit_tone(tone_pairs)?, hue_sat: None }; + let mut look = + CameraLook { matrix, tone: fit_tone(tone_pairs)?, hue_sat: None, provenance: LookProvenance { partial: true, ..Default::default() } }; if let Some(tone) = fit_chroma(&bright, &look) { look.tone = tone; } @@ -959,7 +989,12 @@ fn fit_tone_only_on(sensor: &Rgb32f, reference: &Rgb32f, colour: &Option<(Mat3, }; let tone_pairs: Vec<_> = pairs.iter().enumerate().filter(|(i, _)| i % 3 != 0).map(|(_, (x, y))| (luma(coloured(*x).map(|v| v.max(0.0))), luma(*y))).collect(); - let look = CameraLook { matrix, tone: fit_tone(tone_pairs)?, hue_sat: hue_sat.clone() }; + let look = CameraLook { + matrix, + tone: fit_tone(tone_pairs)?, + hue_sat: hue_sat.clone(), + provenance: LookProvenance { profile: colour.is_some(), ..Default::default() }, + }; let (tone, neutral) = (ToneMap::camera(&look.tone, 0.0, 0.0, 0.0), ToneMap::new(0.0, 0.0, 0.0)); let encoded = |v: f64| v.max(0.0).powf(1.0 / 2.2); let (mut before, mut after, mut before_encoded, mut after_encoded, mut samples) = (0.0, 0.0, 0.0, 0.0, 0); @@ -1701,18 +1736,34 @@ mod tests { } } - /// Step 1: a file's own colour matrices win over everything, including a spectral row for its model; no JPEG fit - /// is tried. + /// An available profile is not necessarily the source of an accepted fit. + #[test] + fn provenance_reports_accepted_path_even_when_profile_is_available() { + for (profile, partial, expected) in [ + (true, false, ColourBasis::CameraProfile { model: "ILCE-7M4".into(), local: false }), + (false, false, ColourBasis::CameraJpeg), + (false, true, ColourBasis::PartialCameraJpeg), + ] { + let mut raw = raw_of(RawFormat::Arw, "SONY", "ILCE-7M4", Default::default()); + let mut look = dro_test_look(&std::array::from_fn(|i| 0.006 * 1.13f32.powi(i as i32)), &|x| x.sqrt()); + look.provenance = LookProvenance { profile, partial, dro_tone_removed: true }; + let (_, _, _, source) = starting_colour_with(&mut raw, |_, _| (Some(look), true), |_, _| None); + assert_eq!(source.basis, expected); + assert!(source.monochrome_tone && source.dro_tone_removed); + } + } + #[test] fn a_files_own_matrices_come_first() { let own = Mat3([[0.6, -0.1, -0.05], [-0.4, 1.3, 0.1], [-0.1, 0.2, 0.7]]); let color = lightcraft_raw::ColorData { illuminant: [21, 0], color_matrix: [Some(own), None], ..Default::default() }; let mut raw = raw_of(RawFormat::Cr2, "Canon", "Canon EOS 600D", color.clone()); - let (_, t, look) = starting_colour_with( + let (_, t, look, source) = starting_colour_with( &mut raw, |_, _| panic!("no JPEG fit for a raw with its own matrices"), |_, _| panic!("no black-and-white JPEG fit for a raw with its own matrices"), ); + assert_eq!(source.basis, ColourBasis::FileMatrices); assert_eq!(raw.color, color); assert!(!t.matrix_is_fallback && look.is_none()); } @@ -1726,7 +1777,7 @@ mod tests { assert!(lightcraft_raw::spectral::find(Some(make), model).is_some(), "{model}"); let mut raw = raw_of(RawFormat::Cr2, make, model, Default::default()); let fitted = dro_test_look(&std::array::from_fn(|i| 0.006 * 1.13f32.powi(i as i32)), &|x| x.sqrt()); - let (xy, t, look) = starting_colour_with( + let (xy, t, look, _) = starting_colour_with( &mut raw, |raw, t| { assert!(t.matrix_is_fallback && !lightcraft_raw::color::has_matrix(&raw.color), "the fit sees the raw without spectral matrices"); @@ -1748,14 +1799,16 @@ mod tests { assert!(crate::camera_profiles::get("ILCE-7M4").is_some()); let camera = lightcraft_raw::spectral::find(Some("SONY"), "ILCE-7M4").unwrap(); let mut raw = raw_of(RawFormat::Arw, "SONY", "ILCE-7M4", Default::default()); - let (_, t, look) = starting_colour(&mut raw, &[]); + let (_, t, look, source) = starting_colour(&mut raw, &[]); + assert_eq!(source.basis, ColourBasis::Spectral); assert!(look.is_none()); assert_eq!(raw.color.color_matrix, camera.color_matrix.map(Some)); assert!(!t.matrix_is_fallback); let camera = lightcraft_raw::spectral::find(Some("Canon"), "Canon EOS 600D").unwrap(); let mut raw = raw_of(RawFormat::Cr2, "Canon", "Canon EOS 600D", Default::default()); - let (xy, t, look) = starting_colour_with(&mut raw, |_, _| (None, false), |_, _| panic!("a colour JPEG never takes the black-and-white step")); + let (xy, t, look, _) = + starting_colour_with(&mut raw, |_, _| (None, false), |_, _| panic!("a colour JPEG never takes the black-and-white step")); assert!(look.is_none()); assert_eq!(raw.color.illuminant, [17, 21]); assert_eq!(raw.color.forward_matrix, camera.forward_matrix.map(Some)); @@ -1772,13 +1825,14 @@ mod tests { #[test] fn a_black_and_white_jpeg_adds_its_tone_on_top_of_the_colour_it_gets_otherwise() { let toned = CameraLook { + provenance: Default::default(), matrix: Mat3::IDENTITY, tone: dro_test_look(&std::array::from_fn(|i| 0.006 * 1.13f32.powi(i as i32)), &|x| x.sqrt()).tone, hue_sat: None, }; let camera = lightcraft_raw::spectral::find(Some("Canon"), "Canon EOS 600D").unwrap(); let mut raw = raw_of(RawFormat::Cr2, "Canon", "Canon EOS 600D", Default::default()); - let (xy, t, look) = starting_colour_with( + let (xy, t, look, _) = starting_colour_with( &mut raw, |_, _| (None, true), |raw, t| { @@ -1791,7 +1845,7 @@ mod tests { assert_eq!(xy, lightcraft_raw::color::as_shot_white_xy(&raw)); let mut raw = raw_of(RawFormat::Cr2, "Canon", "Canon EOS 7D", Default::default()); - let (_, t, look) = starting_colour_with( + let (_, t, look, _) = starting_colour_with( &mut raw, |_, _| (None, true), |_, t| { @@ -1807,7 +1861,8 @@ mod tests { #[test] fn a_camera_outside_the_table_keeps_the_fallback() { let mut raw = raw_of(RawFormat::Cr2, "Canon", "Canon EOS 7D", Default::default()); - let (_, t, look) = starting_colour(&mut raw, &[]); + let (_, t, look, source) = starting_colour(&mut raw, &[]); + assert_eq!(source.basis, ColourBasis::Neutral); assert!(look.is_none() && t.matrix_is_fallback); assert_eq!(raw.color, lightcraft_raw::ColorData::default()); // without a model there is no table row @@ -1836,7 +1891,7 @@ mod tests { let own = lightcraft_raw::color::has_matrix(&raw.color); let covered = raw.metadata.model.as_deref().and_then(|m| lightcraft_raw::spectral::find(raw.metadata.make.as_deref(), m)).is_some(); let before = raw.color.clone(); - let (_, t, fitted) = starting_colour(&mut raw, &bytes); + let (_, t, fitted, _) = starting_colour(&mut raw, &bytes); let spectral = !own && fitted.is_none() && covered; eprintln!("{name}: own matrices {own}, JPEG fit {}, spectral {spectral}", fitted.is_some()); assert_eq!(raw.color != before, spectral, "{name}"); @@ -1984,6 +2039,7 @@ mod tests { } } assert_eq!(look.hue_sat, bundled.hue_sat, "the look's table is not the profile's"); + assert!(look.provenance.profile); } /// A public D7500 NEF (skipped without the corpus): its look is fitted to its own JPEG and white @@ -2065,6 +2121,7 @@ mod tests { /// A look with tone curve `f` at knots `xs` and a colour model and chroma curve to keep. fn dro_test_look(xs: &[f32; 32], f: &dyn Fn(f32) -> f32) -> CameraLook { CameraLook { + provenance: Default::default(), matrix: Mat3([[1.6, -0.4, -0.2], [-0.2, 1.4, -0.2], [0.0, -0.3, 1.3]]), tone: CameraTone::new(xs.map(|x| [x, f(x)])).unwrap().with_chroma([1.3, 1.2, 1.1, 1.0, 1.0, 0.9, 0.6, 0.3]).unwrap(), hue_sat: Some(HsvTable { hue_divisions: 4, sat_divisions: 2, val_divisions: 1, data: vec![[5.0, 1.1, 1.0]; 8], srgb_value: false }), @@ -2114,10 +2171,12 @@ mod tests { let lifted = dro_test_look(&xs, &|x| dro_off.apply(x).powf(0.8)); let fixed = with_dro_off_tone(lifted.clone()); assert_lowered(&lifted, &fixed, "lifted"); + assert!(fixed.provenance.dro_tone_removed); assert!(fixed.tone.apply(0.02) < 0.85 * lifted.tone.apply(0.02)); // a camera that maps raw values darker than Sony's curve keeps its own curve exactly let darker = dro_test_look(&xs, &|x| 0.7 * dro_off.apply(x)); assert_eq!(with_dro_off_tone(darker.clone()).tone, darker.tone); + assert!(!with_dro_off_tone(darker.clone()).provenance.dro_tone_removed); // crossing curves: the lower of the two at the knots, still a valid increasing curve let crossing = dro_test_look(&xs, &|x| (dro_off.apply(x) * (0.6 + x)).min(0.95)); assert_lowered(&crossing, &with_dro_off_tone(crossing.clone()), "crossing"); @@ -2718,7 +2777,7 @@ mod tests { // and the step runs for a model with a bundled profile (the ILCE-7M4 also has spectral matrices) assert!(crate::camera_profiles::get("ILCE-7M4").is_some()); let mut raw = raw_of(RawFormat::Arw, "SONY", "ILCE-7M4", Default::default()); - let (_, t, look) = starting_colour_with( + let (_, t, look, _) = starting_colour_with( &mut raw, |_, _| (None, true), |_, t| { diff --git a/crates/engine/src/camera_profiles.rs b/crates/engine/src/camera_profiles.rs index 6c35c2a45a7..4e5778a640e 100644 --- a/crates/engine/src/camera_profiles.rs +++ b/crates/engine/src/camera_profiles.rs @@ -116,13 +116,25 @@ pub fn save(profile: &CameraProfile, dir: &Path) -> Result { Ok(path) } -fn cache() -> &'static Mutex>>> { - static CACHE: OnceLock>>>> = OnceLock::new(); +/// A resolved profile and its origin, cached together so provenance cannot drift from the data. +#[derive(Clone, Debug)] +pub struct ResolvedProfile { + pub profile: Arc, + pub local: bool, +} + +fn cache() -> &'static Mutex>> { + static CACHE: OnceLock>>> = OnceLock::new(); CACHE.get_or_init(Default::default) } /// The profile for camera `model`: from [`dir`], else built in; read once per process. pub fn get(model: &str) -> Option> { + resolved(model).map(|p| p.profile) +} + +/// The profile and the origin of the exact cached data used by the fitter. +pub fn resolved(model: &str) -> Option { let model = model.trim(); if model.is_empty() { return None; @@ -131,10 +143,16 @@ pub fn get(model: &str) -> Option> { if let Some(hit) = cache.get(model) { return hit.clone(); } - let path = dir().map(|d| d.join(file_name(model))); + let profile = resolve_from(model, dir().as_deref()); + cache.insert(model.to_owned(), profile.clone()); + profile +} + +fn resolve_from(model: &str, directory: Option<&Path>) -> Option { + let path = directory.map(|d| d.join(file_name(model))); let profile = match path { Some(path) if path.is_file() => match load(&path) { - Ok(p) if p.model.trim() == model => Some(Arc::new(p)), + Ok(p) if p.model.trim() == model => Some(ResolvedProfile { profile: Arc::new(p), local: true }), Ok(p) => { eprintln!("lightcraft: ignoring camera profile {}: it is for {:?}, not {model:?}", path.display(), p.model); None @@ -146,9 +164,7 @@ pub fn get(model: &str) -> Option> { }, _ => None, }; - let profile = profile.or_else(|| bundled(model).map(Arc::new)); - cache.insert(model.to_owned(), profile.clone()); - profile + profile.or_else(|| bundled(model).map(|p| ResolvedProfile { profile: Arc::new(p), local: false })) } /// Changes when the profiles folder's contents change (per process): part of the render cache @@ -288,6 +304,28 @@ mod tests { assert!(bundled("No Such Camera").is_none()); } + #[test] + fn provenance_follows_validated_profile_not_file_presence() { + let dir = std::env::temp_dir().join(format!("lc-profile-origin-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let path = dir.join(file_name("ILCE-7M4")); + let builtin = resolve_from("ILCE-7M4", None).unwrap(); + assert!(!builtin.local); + let local = profile(); + save(&local, &dir).unwrap(); + let resolved = resolve_from("ILCE-7M4", Some(&dir)).unwrap(); + assert!(resolved.local); + assert_eq!(*resolved.profile, local); + std::fs::write(&path, b"broken").unwrap(); + assert!(!resolve_from("ILCE-7M4", Some(&dir)).unwrap().local); + let mut other = local; + other.model = "another model".into(); + std::fs::write(&path, serde_json::to_vec(&other).unwrap()).unwrap(); + assert!(!resolve_from("ILCE-7M4", Some(&dir)).unwrap().local); + assert!(resolve_from("No Such Camera", Some(&dir)).is_none()); + let _ = std::fs::remove_dir_all(dir); + } + #[test] fn file_names_are_safe() { assert_eq!(file_name("ILCE-7M4"), "ILCE-7M4.json"); diff --git a/crates/engine/src/files.rs b/crates/engine/src/files.rs index c48aaff77c2..12950b0f2bc 100644 --- a/crates/engine/src/files.rs +++ b/crates/engine/src/files.rs @@ -403,7 +403,8 @@ fn load_bytes_now( // the camera's measured matrices (`Photo::relative_wb` decides the same from the catalog's camera) let scale = WbScaleOf::new(raw.format, &raw.color, raw.wb_multipliers, &raw.metadata); // the source's segmentation mattes (DNG semantic masks), read while the starting colour is fitted - let ((xy, t, camera_look), mattes) = rayon::join(|| crate::camera_preview::starting_colour(&mut raw, &bytes), || dng_mattes(&bytes, &info)); + let ((xy, t, camera_look, colour_source), mattes) = + rayon::join(|| crate::camera_preview::starting_colour(&mut raw, &bytes), || dng_mattes(&bytes, &info)); drop(bytes); // Previews and thumbnails bin the mosaic straight to (about) the size they need; only // larger levels (exports, 1:1) demosaic the whole sensor. @@ -491,6 +492,7 @@ fn load_bytes_now( legacy_relative_wb: scale.legacy_relative, camera_color, camera_tone, + colour_source: Some(colour_source), mattes, local_tone, }, diff --git a/crates/engine/src/media.rs b/crates/engine/src/media.rs index 6f6f0359c45..1a7bcfa2316 100644 --- a/crates/engine/src/media.rs +++ b/crates/engine/src/media.rs @@ -305,6 +305,8 @@ impl SourceRef { pub struct MediaCache { settings_hashes: SettingsHashes, + /// Bounded diagnostics from workers that keep decoded pixels in another address space. + remote_colour: Lru, /// Decoded thumbnail-level sources (LRU by bytes). thumbs: Lru, /// Decoded preview-level sources with their last use ([`lightcraft_preview::next_tick`]). @@ -387,6 +389,7 @@ impl Default for MediaCache { let budget = crate::memory::cache_share(crate::memory::budget()); MediaCache { settings_hashes: SettingsHashes::default(), + remote_colour: Lru::new(64 << 10), thumbs: Lru::new(THUMB_SOURCE_BYTES.min(budget)), previews: Vec::new(), full: Vec::new(), @@ -433,6 +436,7 @@ impl MediaCache { /// Forget every decoded source (photo ids changed meaning, e.g. another library was opened). pub fn clear_sources(&mut self) { self.settings_hashes = SettingsHashes::default(); + self.remote_colour = Lru::new(64 << 10); self.thumbs = Lru::new(THUMB_SOURCE_BYTES.min(self.budget)); self.previews.clear(); self.full.clear(); @@ -565,6 +569,7 @@ impl MediaCache { /// Forget a photo's decoded sources (e.g. after its file changed). pub fn forget(&mut self, id: PhotoId) { + self.remote_colour.remove(&id); self.thumbs.remove(&id); self.previews.retain(|e| e.0 != id); self.full.retain(|e| e.0 != id); @@ -714,6 +719,8 @@ pub struct RenderResult { pub gpu_fallback: Option, /// A source that was loaded by this job (to be inserted into the cache). pub loaded: Option, + /// Diagnostic facts returned by an out-of-process worker; requires a matching source key. + pub colour_source: Option, /// Set for a [`QuickJob`]'s stand-in: where the image came from. pub quick: Option, /// The display profile (id) the image is encoded for; `None`: sRGB (see @@ -818,6 +825,7 @@ impl RenderJob { rendered: Ok(Rendered { image, histogram, deep: None }), gpu_fallback: None, loaded: None, + colour_source: None, quick: None, display: None, }; @@ -873,6 +881,7 @@ impl RenderJob { rendered: Ok(rendered), gpu_fallback, loaded: (!was_loaded).then_some(source), + colour_source: None, quick: None, display, } @@ -886,6 +895,7 @@ impl RenderJob { rendered: Err(e), gpu_fallback: None, loaded: None, + colour_source: None, quick: None, display: None, }, @@ -988,6 +998,7 @@ impl QuickJob { rendered, gpu_fallback: None, loaded: None, + colour_source: None, quick, display: None, }; @@ -1374,6 +1385,17 @@ impl crate::Session { /// Accept a finished job's loaded source into the cache. What the decode learnt about the file that the catalog /// has wrong is corrected too ([`Self::learn_as_shot_wb`]). pub fn accept(&mut self, r: &RenderResult) { + if r.rendered.is_ok() + && let (Some(key), Some(source)) = (r.source_key, &r.colour_source) + && self.catalog.photo(r.photo).is_some_and(|p| Hasher128::new().str(&content_key(p)).finish() == key) + { + let cost = 128 + + match &source.basis { + lightcraft_pipeline::ColourBasis::CameraProfile { model, .. } => model.len(), + _ => 0, + }; + self.media.remote_colour.insert(r.photo, (key, source.clone()), cost); + } if let Some(src) = &r.loaded && r.source_key.is_none_or(|key| self.catalog.photo(r.photo).is_some_and(|p| Hasher128::new().str(&content_key(p)).finish() == key)) { @@ -1454,7 +1476,14 @@ impl crate::Session { /// Prefer decoder facts to header-only metadata for pixel-statistics commands. pub fn source_info(&self, id: PhotoId) -> SourceInfo { let header = self.catalog.photo(id).map(|p| source_info(p)).unwrap_or_default(); - self.media.source_facts(id, header) + let mut info = self.media.source_facts(id, header); + if info.colour_source.is_none() + && let Some((key, source)) = self.media.remote_colour.peek(&id) + && self.catalog.photo(id).is_some_and(|p| Hasher128::new().str(&content_key(p)).finish() == *key) + { + info.colour_source = Some(source.clone()); + } + info } /// The source proxy for pixel-statistics commands (auto tone/WB), loading synchronously. @@ -1625,6 +1654,33 @@ mod tests { assert_eq!(s.catalog.photo(id).unwrap().develop.grading.shadows.sat, 60.0, "the edit is untouched"); } + #[test] + fn worker_provenance_requires_a_current_source_and_is_forgotten() { + let mut s = crate::Session::with_demo(); + let id = s.active().unwrap(); + let mut result = s.loupe_job(id, 32, 32, true).unwrap().run(); + result.loaded = None; // Workers retain their pixels in a separate address space. + let source = + lightcraft_pipeline::ColourSource { basis: lightcraft_pipeline::ColourBasis::Spectral, monochrome_tone: false, dro_tone_removed: false }; + result.colour_source = Some(source.clone()); + let current_key = result.source_key; + result.source_key = None; + s.accept(&result); + assert!(s.source_info(id).colour_source.is_none()); + result.source_key = Some(Hasher128::new().str("different original").finish()); + s.accept(&result); + assert!(s.source_info(id).colour_source.is_none()); + result.source_key = current_key; + s.accept(&result); + assert_eq!(s.source_info(id).colour_source, Some(source.clone())); + s.media.forget(id); + assert!(s.source_info(id).colour_source.is_none()); + s.accept(&result); + assert_eq!(s.source_info(id).colour_source, Some(source)); + s.media.clear_sources(); + assert!(s.source_info(id).colour_source.is_none()); + } + #[test] fn decoder_info_survives_render_jobs_cache_and_eviction() { let tone = lightcraft_pipeline::tone::CameraTone::new(std::array::from_fn(|i| { @@ -1632,7 +1688,10 @@ mod tests { [x, (x * 2.0).min(0.9)] })) .unwrap(); - let info = SourceInfo { raw: true, relative_wb: true, camera_tone: Some(tone), ..Default::default() }; + let colour_source = + lightcraft_pipeline::ColourSource { basis: lightcraft_pipeline::ColourBasis::Spectral, monochrome_tone: false, dro_tone_removed: false }; + let info = + SourceInfo { raw: true, relative_wb: true, camera_tone: Some(tone), colour_source: Some(colour_source.clone()), ..Default::default() }; let mut s = crate::Session::with_demo(); let id = s.active().unwrap(); let mut job = s.render_job(id, 64, 64, false, true).unwrap(); @@ -1655,12 +1714,16 @@ mod tests { let expected = lightcraft_pipeline::render(&r.loaded.as_ref().unwrap().image, &info, &job.settings, &job.request); assert_eq!(r.rendered.as_ref().unwrap().image.data, expected.image.data); s.accept(&r); + assert_eq!(s.source_info(id).colour_source, Some(colour_source)); + let other = s.visible_cloned().into_iter().find(|other| *other != id).unwrap(); + assert!(s.source_info(other).colour_source.is_none(), "never borrow another photo's source"); job.source = s.media.source_ref(s.catalog.photo(id).unwrap(), job.level); let again = job.run(); assert!(again.loaded.is_none()); assert_eq!(r.rendered.unwrap().image.data, again.rendered.unwrap().image.data); s.media.forget(id); assert!(s.media.get_source(id, r.level).is_none()); + assert!(s.source_info(id).colour_source.is_none(), "eviction must not leave stale provenance"); } /// Issue #730: an ILCE-7M3 ARW from an older catalog (white balance relative to the as-shot look, 6500 / 0 as diff --git a/crates/pipeline/src/lib.rs b/crates/pipeline/src/lib.rs index 6fbb156e89e..1c07565f52e 100644 --- a/crates/pipeline/src/lib.rs +++ b/crates/pipeline/src/lib.rs @@ -67,9 +67,30 @@ pub struct CameraColor { pub developed_for: lightcraft_color::Xy, } +/// The colour actually used while decoding a raw, independent of the editable creative profile. +#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub enum ColourBasis { + FileMatrices, + CameraProfile { model: String, local: bool }, + CameraJpeg, + PartialCameraJpeg, + Spectral, + Neutral, +} + +/// Diagnostic facts only: these never change rendering or cache keys. +#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct ColourSource { + pub basis: ColourBasis, + pub monochrome_tone: bool, + pub dro_tone_removed: bool, +} + /// Facts about the source the settings are interpreted against. #[derive(Clone, Debug, PartialEq)] pub struct SourceInfo { + /// None until a raw has been decoded, or for a rendered image / old smart preview. + pub colour_source: Option, /// Lens corrections embedded in the file (DNG opcodes), relative to the EXIF-oriented source. pub lens: Option, /// Raw sources use absolute Kelvin white balance; rendered sources use a relative scale around @@ -97,6 +118,7 @@ pub struct SourceInfo { impl Default for SourceInfo { fn default() -> Self { Self { + colour_source: None, raw: false, as_shot_temp: 6500.0, as_shot_tint: 0.0, diff --git a/crates/ui-egui/locales/de-formats.json b/crates/ui-egui/locales/de-formats.json index 7bcaf9f2052..5b600d0f980 100644 --- a/crates/ui-egui/locales/de-formats.json +++ b/crates/ui-egui/locales/de-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "nicht zu Apple Fotos hinzugefügt: {e}", "{n} added to Apple Photos album “{album}”": "{n} zum Apple-Fotos-Album „{album}“ hinzugefügt", "{n} added to Apple Photos": "{n} zu Apple Fotos hinzugefügt", - "{n} photos opened for editing; each is stacked with its original": "{n} Fotos zur Bearbeitung geöffnet; jedes ist mit seinem Original gestapelt" + "{n} photos opened for editing; each is stacked with its original": "{n} Fotos zur Bearbeitung geöffnet; jedes ist mit seinem Original gestapelt", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/es-formats.json b/crates/ui-egui/locales/es-formats.json index 3dd94a934ee..9fc72533ba6 100644 --- a/crates/ui-egui/locales/es-formats.json +++ b/crates/ui-egui/locales/es-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "no se añadieron a Fotos de Apple: {e}", "{n} added to Apple Photos album “{album}”": "{n} añadidas al álbum “{album}” de Fotos de Apple", "{n} added to Apple Photos": "{n} añadidas a Fotos de Apple", - "{n} photos opened for editing; each is stacked with its original": "{n} fotos abiertas para editar; cada una está apilada con su original" + "{n} photos opened for editing; each is stacked with its original": "{n} fotos abiertas para editar; cada una está apilada con su original", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/fr-formats.json b/crates/ui-egui/locales/fr-formats.json index 65cf9731181..9afb8d066a3 100644 --- a/crates/ui-egui/locales/fr-formats.json +++ b/crates/ui-egui/locales/fr-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "non ajouté à Apple Photos : {e}", "{n} added to Apple Photos album “{album}”": "{n} ajouté(s) à l'album Apple Photos « {album} »", "{n} added to Apple Photos": "{n} ajouté(s) à Apple Photos", - "{n} photos opened for editing; each is stacked with its original": "{n} photos ouvertes pour modification ; chacune est empilée avec son original" + "{n} photos opened for editing; each is stacked with its original": "{n} photos ouvertes pour modification ; chacune est empilée avec son original", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/ja-formats.json b/crates/ui-egui/locales/ja-formats.json index ca286386dc5..a54f28f547b 100644 --- a/crates/ui-egui/locales/ja-formats.json +++ b/crates/ui-egui/locales/ja-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "Appleの写真に追加されませんでした:{e}", "{n} added to Apple Photos album “{album}”": "{n}件をAppleの写真のアルバム「{album}」に追加しました", "{n} added to Apple Photos": "{n}件をAppleの写真に追加しました", - "{n} photos opened for editing; each is stacked with its original": "{n}枚の写真を編集用に開きました。それぞれ元の写真とスタックされています" + "{n} photos opened for editing; each is stacked with its original": "{n}枚の写真を編集用に開きました。それぞれ元の写真とスタックされています", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/pt-br-formats.json b/crates/ui-egui/locales/pt-br-formats.json index 0b3ebe80d43..5269654be2d 100644 --- a/crates/ui-egui/locales/pt-br-formats.json +++ b/crates/ui-egui/locales/pt-br-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "não adicionadas ao Fotos da Apple: {e}", "{n} added to Apple Photos album “{album}”": "{n} adicionadas ao álbum “{album}” do Fotos da Apple", "{n} added to Apple Photos": "{n} adicionadas ao Fotos da Apple", - "{n} photos opened for editing; each is stacked with its original": "{n} fotos abertas para edição; cada uma está empilhada com a original" + "{n} photos opened for editing; each is stacked with its original": "{n} fotos abertas para edição; cada uma está empilhada com a original", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/ru-formats.json b/crates/ui-egui/locales/ru-formats.json index 11651aaa0f6..c0ee08adcc6 100644 --- a/crates/ui-egui/locales/ru-formats.json +++ b/crates/ui-egui/locales/ru-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "не добавлено в Apple Фото: {e}", "{n} added to Apple Photos album “{album}”": "Добавлено в альбом «{album}» Apple Фото: {n}", "{n} added to Apple Photos": "Добавлено в Apple Фото: {n}", - "{n} photos opened for editing; each is stacked with its original": "Открыто для редактирования фото: {n}; каждое объединено в стопку с оригиналом" + "{n} photos opened for editing; each is stacked with its original": "Открыто для редактирования фото: {n}; каждое объединено в стопку с оригиналом", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/uk-formats.json b/crates/ui-egui/locales/uk-formats.json index 7aca485e0f2..558f9f3efaf 100644 --- a/crates/ui-egui/locales/uk-formats.json +++ b/crates/ui-egui/locales/uk-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "не додано до Apple Фото: {e}", "{n} added to Apple Photos album “{album}”": "Додано до альбому Apple Фото «{album}»: {n}", "{n} added to Apple Photos": "Додано до Apple Фото: {n}", - "{n} photos opened for editing; each is stacked with its original": "Відкрито для редагування фото: {n}; кожне об’єднано в стос з оригіналом" + "{n} photos opened for editing; each is stacked with its original": "Відкрито для редагування фото: {n}; кожне об’єднано в стос з оригіналом", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/zh-hans-formats.json b/crates/ui-egui/locales/zh-hans-formats.json index bf27ca6b2c7..29badba0f21 100644 --- a/crates/ui-egui/locales/zh-hans-formats.json +++ b/crates/ui-egui/locales/zh-hans-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "未添加到 Apple 照片:{e}", "{n} added to Apple Photos album “{album}”": "已将 {n} 个添加到 Apple 照片相册“{album}”", "{n} added to Apple Photos": "已将 {n} 个添加到 Apple 照片", - "{n} photos opened for editing; each is stacked with its original": "已打开 {n} 张照片进行编辑;每张都与其原片堆叠在一起" + "{n} photos opened for editing; each is stacked with its original": "已打开 {n} 张照片进行编辑;每张都与其原片堆叠在一起", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/locales/zh-hant-formats.json b/crates/ui-egui/locales/zh-hant-formats.json index 37b2db2ba96..4287cc667e0 100644 --- a/crates/ui-egui/locales/zh-hant-formats.json +++ b/crates/ui-egui/locales/zh-hant-formats.json @@ -244,5 +244,7 @@ "not added to Apple Photos: {e}": "未加入 Apple 照片:{e}", "{n} added to Apple Photos album “{album}”": "已將 {n} 個加入 Apple 照片相簿「{album}」", "{n} added to Apple Photos": "已將 {n} 個加入 Apple 照片", - "{n} photos opened for editing; each is stacked with its original": "已開啟 {n} 張相片進行編輯;每張都與其原始相片堆疊在一起" + "{n} photos opened for editing; each is stacked with its original": "已開啟 {n} 張相片進行編輯;每張都與其原始相片堆疊在一起", + "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", + "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" } diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rs index ed2ee46359f..bc6d727af0a 100644 --- a/crates/ui-egui/src/panels/edit.rs +++ b/crates/ui-egui/src/panels/edit.rs @@ -165,6 +165,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { } }); }); + super::profiles::colour_source(app, ui, id); }); if d.profile.id != "lc.color" { control(app, ui, &d, "profile.amount", true); diff --git a/crates/ui-egui/src/panels/profiles.rs b/crates/ui-egui/src/panels/profiles.rs index 6294d1e64c2..f5b002adf6c 100644 --- a/crates/ui-egui/src/panels/profiles.rs +++ b/crates/ui-egui/src/panels/profiles.rs @@ -42,6 +42,9 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { t.font(14.0), t.text_label, ); + egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 0, bottom: 10 }).show(ui, |ui| { + colour_source(app, ui, id); + }); if d.profile.id != "lc.color" { super::edit::control(app, ui, &d, "profile.amount", true); ui.add_space(6.0); @@ -209,3 +212,98 @@ fn cell_ui( } } } + +/// Read from the selected photo's decoded source, never from the previously displayed preview. +pub(super) fn colour_source(app: &LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { + if !app.session.catalog.photo(id).is_some_and(|p| p.develops_raw()) { + return; + } + let info = app.session.source_info(id); + let text = colour_source_text(info.colour_source.as_ref()); + let t = Tokens::get(ui.ctx()); + let response = ui.add(egui::Label::new(egui::RichText::new(text).font(t.font(12.0)).color(t.text_dim)).wrap()); + register(ui.ctx(), "label:cameraColourSource", response.rect); +} + +fn colour_source_text(source: Option<&lightcraft_pipeline::ColourSource>) -> String { + use lightcraft_pipeline::ColourBasis; + let Some(source) = source else { return crate::i18n::tr("Camera colour: not available until the original is decoded").to_string() }; + let mut label = match &source.basis { + ColourBasis::FileMatrices => crate::i18n::tr("Camera colour: raw's own matrices").to_string(), + ColourBasis::CameraProfile { model, local } => { + if *local { + crate::i18n::tr_format!("Camera colour: {model} profile (local)", model = model) + } else { + crate::i18n::tr_format!("Camera colour: {model} profile (built in)", model = model) + } + } + ColourBasis::CameraJpeg => crate::i18n::tr("Camera colour: fitted to the camera JPEG").to_string(), + ColourBasis::PartialCameraJpeg => crate::i18n::tr("Camera colour: partial camera JPEG fit").to_string(), + ColourBasis::Spectral => crate::i18n::tr("Camera colour: spectral sensitivities (no accepted colour fit)").to_string(), + ColourBasis::Neutral => crate::i18n::tr("Camera colour: neutral (no accepted colour fit)").to_string(), + }; + if source.monochrome_tone { + label.push_str(" · "); + label.push_str(crate::i18n::tr("Tone from black-and-white camera JPEG")); + } + if source.dro_tone_removed { + label.push_str(" · "); + label.push_str(crate::i18n::tr("DRO tone removed")); + } + label +} + +#[cfg(test)] +mod tests { + use super::*; + use lightcraft_catalog::{MediaKind, Op, Photo, Source}; + use lightcraft_engine::media::SourceLevel; + use lightcraft_pipeline::{ColourBasis, ColourSource, SourceInfo}; + use std::{sync::Arc, time::Duration}; + + #[test] + fn colour_readout_follows_selection_in_both_panels() { + let mut session = lightcraft_engine::Session::new(); + let mut ids = Vec::new(); + for (name, format, kind) in + [("first.ARW", "ARW", MediaKind::Raw), ("second.ARW", "ARW", MediaKind::Raw), ("rendered.jpg", "JPEG", MediaKind::Image)] + { + let id = session.catalog.alloc_photo_id(); + let mut photo = Photo::new(id, Source::File { path: name.into() }, name, format, 32, 32, "2026-10-12T00:00:00"); + photo.kind = kind; + session.catalog.apply(Op::AddPhoto { photo: Box::new(photo) }).unwrap(); + ids.push(id); + } + session.media.file_loader = Some(Arc::new(|path, _| { + let basis = + if path == "first.ARW" { ColourBasis::CameraProfile { model: "Test Camera".into(), local: true } } else { ColourBasis::Spectral }; + Ok(( + lightcraft_raster::Rgb32f::new(32, 32), + SourceInfo { + raw: true, + colour_source: Some(ColourSource { basis, monochrome_tone: false, dro_tone_removed: false }), + ..Default::default() + }, + )) + })); + for id in &ids { + session.source_now(*id, SourceLevel::Preview).unwrap(); + } + let app = LightcraftApp::new(session, crate::Services { png: None, ..Default::default() }); + let mut h = crate::headless::Headless::new(app, [1400.0, 900.0], 1.0); + let timeout = Duration::from_secs(30); + for panel in ["edit", "profiles"] { + for (i, id) in ids.iter().enumerate() { + h.request("engine.execute", json!({"command":"library.select", "params":{"ids":[id.0], "active":id.0}}), timeout); + h.request("ui.set", json!({"view":"detail", "right":panel}), timeout); + h.step(); + assert_eq!(h.app.widgets.iter().any(|(name, _)| name == "label:cameraColourSource"), i < 2, "{panel}: {i}"); + if i < 2 { + let text = h.painted_text().join("\n"); + assert_eq!(text.contains("Test Camera"), i == 0, "{text}"); + } + } + } + assert!(!colour_source_text(None).contains("Test Camera")); + } +} diff --git a/docs/camera-preview-colour.md b/docs/camera-preview-colour.md index b24d9bf75cc..f4afa38f060 100644 --- a/docs/camera-preview-colour.md +++ b/docs/camera-preview-colour.md @@ -180,3 +180,20 @@ the neutral fallback): E-1 0.126 → 0.014, E-400 0.087 → 0.022, XZ-2 0.061 still open from their embedded JPEG. Against Lightroom Classic's render of a CC0 E-1 photo (2000 px, ΔE00 of the unedited render) the starting look moved from 11.25 to 8.30. Lightroom frames that E-1 file about 4 × 11 sensor pixels differently from the crop the file records (`CropLeft`/`CropTop` 36, 34); the file's own crop is kept. + +## Starting-colour readout (#1310) + +The Edit panel and profile browser show the decoded original's starting-colour source below +its creative profile: the file's matrices, an accepted built-in/local camera profile, its own +camera-JPEG fit, a partial fit, spectral sensitivities, or neutral fallback. A profile's presence +alone never implies it was accepted. Black-and-white JPEG tone and an actual DRO tone change +are noted separately. This is diagnostic metadata; pixel calculations, `LOOK_VERSION`, and +render-cache versions do not change. + +The readout follows the selected photo's decoded source cache. Before decoding (including an +old/offline smart preview without these facts), it says the source is unavailable rather than +inferring it from the model or reusing the previous photo's label. + +Browser render workers return the same provenance without transferring decoded pixels. The +main thread keeps a bounded diagnostic cache keyed by photo and original identity; replacing +the file or clearing sources discards it. Cached JPEG thumbnails alone cannot establish provenance. diff --git a/docs/gaps.md b/docs/gaps.md index 7c4f56223c6..b134fd864b2 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Gaps: where LightCraft falls short of Lightroom -> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-11 · **Change:** minor (CR3 entry names the EOS R7 C-RAW fix and the refused CRX variants; CI and Windows / Linux entries note the 0.6.0 riscv64 build; camera colour: tone curve from black-and-white camera JPEGs; Compare and Reference get sharp zoom windows; gap 4 shrinks; gap 14: the HDR switch is read from crs XMP; gaps 2 and 10: EOS R5 Mark II CR3 verified) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 +> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-12 · **Change:** minor (starting-colour provenance readout #1310; CR3 entry names the EOS R7 C-RAW fix and the refused CRX variants; CI and Windows / Linux entries note the 0.6.0 riscv64 build; camera colour: tone curve from black-and-white camera JPEGs; Compare and Reference get sharp zoom windows; gap 4 shrinks; gap 14: the HDR switch is read from crs XMP; gaps 2 and 10: EOS R5 Mark II CR3 verified) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 Every known shortfall, one entry each, ranked by user impact (how many Lightroom users hit it, and how hard it blocks them), then by effort. **Agents pick work from the top** (the first entry nobody is @@ -15,7 +15,7 @@ Hours are Opus 5.5 agent wall-clock hours (see [target-app-parity.md](target-app | # | Gap | Evidence | User impact | Hours | Doc | |---:|---|---|---|---:|---| -| 1 B | **Camera colour is estimated, not measured** (LR-PROF-CAMERACOLOR). Raws start from a per-file fit to the camera JPEG, 4 bundled profiles or 52 spectral matrices; others use a neutral matrix (a black-and-white camera JPEG gives its tone curve only, #577) | ΔE vs camera JPEG 2.9–10 after fitting (raw-parity.md); 0 chart-calibrated models vs 1,500 Adobe Standard profiles | every raw shooter sees colour that is close but not Lightroom's; some get neutral-matrix colour | 50–90 | [raw-parity](raw-parity.md#colour) | +| 1 B | **Camera colour is estimated, not measured** (LR-PROF-CAMERACOLOR). The Profile panel reports the decoded starting-colour path (#1310); calibration accuracy remains a gap. Raws start from a per-file fit to the camera JPEG, 4 bundled profiles or 52 spectral matrices; others use a neutral matrix (a black-and-white camera JPEG gives its tone curve only, #577) | ΔE vs camera JPEG 2.9–10 after fitting (raw-parity.md); 0 chart-calibrated models vs 1,500 Adobe Standard profiles | every raw shooter sees colour that is close but not Lightroom's; some get neutral-matrix colour | 50–90 | [raw-parity](raw-parity.md#colour) | | 2 B | **CR3 beyond four verified bodies** (LR-IMP-FORMATS): `crx.rs` refuses vertical-tile C-RAW, partial-subband and other plane coding, multi-tile 0x200 and adaptive low-frequency gains, and those files fall back to the preview; CR3 sRAW / mRAW and HEIF CR3 too. Verified: M50 / R100 / R8 / R5 Mark II. EOS R7 C-RAW (odd-height QP map) decodes since a45c2b66 and R6 Mark II C-RAW is reported working on 0.6.0, but neither is verified yet (no corpus test or recorded check) | measured: Canon is the largest bucket (33% of photographers) and its share whose camera fully works is the lowest of the big four, 73%; 18 of 22 popular Canon bodies write CR3, 4 verified (raw-parity.md); R7 rule checked only on paired RAW / C-RAW captures ([cr3.md](cr3.md)) | +6.2 points of photographers whose camera works, the biggest single raw gain | 25–45 | [raw-parity](raw-parity.md#remaining-work-ranked-by-photographers-unlocked-per-hour) | | 3 B | **Render fidelity unmeasured** (LR-BEHAV-RENDER-FIDELITY): tone, highlights, texture / clarity / dehaze, NR and sharpening are tuned by eye | no side-by-side suite; a retune needs a new process version (only V1 exists) | edits imported from Lightroom look different; the look "isn't Lightroom's" | 30–60 | [raw-parity](raw-parity.md), [process-versions](process-versions.md) | | 4 B | **Original-pixel detail at 100%** (LR-VIEW-ZOOM, P0): Detail, Before/After, Compare and Reference are sharp at 1:1–8:1 (zoom windows, #323). Mask overlays and soft proofing still render the whole frame at the drawn size instead of a window: sharp up to the GPU texture side, but a full-size render per edit at 1:1 | checklist row 🟡 | editing with a mask overlay or soft proof on at 1:1 is slow on large files, and blurry past the texture side | 4–8 | [ui-parity](ui-parity.md) | @@ -72,6 +72,7 @@ Beta-blocking gaps (B) total **~230–430 h**; with the stability and platform w | Date | Change | Summary | |---|---|---| +| 2026-10-12 | minor | #1310: Profile panel starting-colour provenance; calibration gap and readiness unchanged | | 2026-10-11 | minor | Reviewed against main after 0.6.0: CR3 entry names the CRX variants `crx.rs` still refuses and the R7 / R6 Mark II C-RAW state (decoding, not verified, so the measured numbers don't move); CI and Windows / Linux entries note the riscv64 release build (#844); R7 fix added to Closed recently. Panel docking (UI.9, #869) closes no listed gap | | 2026-10-11 | minor | Camera colour entry: raws with a black-and-white camera JPEG take its tone curve (#577); gap not closed | | 2026-10-11 | minor | Gap 4: Compare and Reference views get zoom windows per pane (1:1 was a 2,560 px render magnified); overlays and soft proofing remain, 8–15 h → 4–8 h | diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 77ae26e4c53..d866e8f51c2 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -1,6 +1,6 @@ # Lightroom parity checklist -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (rapid slider entry; LR-PROF-CAMERACOLOR: tone curve from black-and-white camera JPEGs; LR-VIEW-ZOOM, LR-VIEW-COMPARE: Compare and Reference zoom windows; LR-IMP-FORMATS, LR-IMP-CAMERA-COVERAGE: EOS R5 Mark II CR3 decodes; renamed from `parity.md`; Top gaps moved to gaps.md, shortcut notes to ui-parity.md; filesystem history retry/Undo/Redo evidence; renamed from `parity.md`; Top gaps moved to gaps.md, shortcut notes to ui-parity.md) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (starting-colour provenance readout #1310; rapid slider entry; LR-PROF-CAMERACOLOR: tone curve from black-and-white camera JPEGs; LR-VIEW-ZOOM, LR-VIEW-COMPARE: Compare and Reference zoom windows; LR-IMP-FORMATS, LR-IMP-CAMERA-COVERAGE: EOS R5 Mark II CR3 decodes; renamed from `parity.md`; Top gaps moved to gaps.md, shortcut notes to ui-parity.md; filesystem history retry/Undo/Redo evidence; renamed from `parity.md`; Top gaps moved to gaps.md, shortcut notes to ui-parity.md) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 The measured, row-by-row checklist: one row per Lightroom feature, menu item and shortcut, what we have and what is missing. It answers *does the feature exist?* (feature breadth). Whether it is good @@ -234,7 +234,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-PROF-ADOBE | Standard raw looks (own equivalents) | P0 | ✅ | `crates/engine/src/presets.rs` (`PROFILES`), `crates/pipeline/src/profiles.rs` | six own looks: Color, Neutral, Vivid, Landscape, Portrait, Monochrome | | LR-PROF-ADAPTIVE | Adaptive profiles | P2 | ⬜ | | | | LR-PROF-CAMERA | Camera-matching looks | P2 | ⬜ | | | -| LR-PROF-CAMERACOLOR | Camera colour calibration (own) | P0 | 🟡 | `crates/raw/src/color.rs`, `crates/raw/src/profile.rs`, `crates/raw/src/gaintable.rs`, `crates/engine/src/camera_preview.rs` | DNG files use the colour matrices and the camera-profile look they carry (`ProfileHueSatMap`, `ProfileLookTable`, `ProfileToneCurve`, read from the file at run time per DNG spec ch. 6 — Lightroom-converted DNGs rendered flat and muted without them, issue #138). A DNG's `ProfileGainTableMap` / `ProfileGainTableMap2` (Apple ProRAW's local tone map; both versions, DNG 1.7 precedence, the file's byte order with a big-endian fallback) is read and written back by DNG export and not rendered by default, as Lightroom Classic renders ProRAW without it (measured on one CC0 iPhone 12 Pro ProRAW); the Profile option "Camera local tone mapping" (`profile.camera_local_tone`, per photo, off by default, `crates/pipeline/src/local_tone.rs`) renders it as the camera does, per output pixel in the scene-linear stage (CPU, also under the GPU path); Sony ARW, Nikon NEF, Panasonic RW2, Fujifilm RAF, Canon CR3 and CR2, Pentax PEF, Samsung SRW and Olympus ORF get a guarded file-local fit to their own embedded JPEG — chromaticity matrix + hue/saturation/value table + tone and chroma curves, relative WB — or, with a bundled or local per-model profile pooled from many photos (`lightcraft-cli calibrate`, ARW, NEF and RAF so far, `crates/engine/src/camera_profiles.rs`), the profile's colour and only their own tone/chroma curves (on 29 held-out ILCE-7M4 photos mean ΔE vs the camera JPEG 3.54 → 3.10; bundled ILCE-7CR from 125 photos: 26 held-out 4.07 → 3.29, and every one of the 131 photos accepted, 8 of which fell back to neutral without it), kept with smart previews (see docs/camera-preview-colour.md); Sony ARWs shot with DRO on (maker note `0xb025`, on by default) keep that colour but their tone curve is lowered to Sony's curve without DRO, whose lifted shadows are in the camera JPEG only (issue #244: 8 ILCE-7CR photos +6.4 → +0.8 L* from Lightroom's default, median ΔE 7.5 → 3.3); 52 models without a profile whose JPEG fit fails (or that have no usable JPEG) start from DNG-style matrices fitted to their measured spectral sensitivities instead of the neutral fallback (`crates/raw/src/spectral.rs`, rawtoaces-data v1.1.0, Apache-2.0, aliases included; not yet measured against the camera JPEG); ARW: on 10 public raw.pixls.us samples from 8 bodies 7 fits were accepted, mean ΔE vs the camera JPEG 17–26 → 3–10; NEF: 13 of 13 decodable samples (D750, D780, D850, D7500, Z 50 and local D7500 shots) accepted, ΔE 13–46 → 3–8 (issue #150); RW2 / RWL: 140 of 174 public samples accepted, from 93 of the 114 bodies with a preview, median ΔE 5.0 with matching lightness (13 of the 14 corpus files with a preview: ΔE 9.6–27 → 2.8–8.9; most rejections are compacts and kit zooms whose camera JPEG is distortion-corrected); a fit that fails the gates on all pixels is retried away from edges, where a lens-corrected camera JPEG still lines up (issue #232: the six distortion-corrected public ILCE-7RM2 samples ΔE 16.6–16.9 → 3.7–3.8, the corpus GX80 19.1 → 7.9); RAF: bundled X-H2S/X-T4 profiles from 201/545 photos; on 150 withheld files mean ΔE improves slightly over per-file fitting (X-H2S 1.70 → 1.62, X-T4 2.43 → 2.34); 23 of 24 references from 13 bodies accepted, including the dark X-H2S samples (8.74 → 2.25); ORF: the 3 decodable corpus files (E-1, E-400, XZ-2) accepted (`docs/camera-preview-colour.md`); a raw whose camera JPEG is black and white (a monochrome picture style) takes only the JPEG's tone curve, on the camera profile's, spectral or neutral colour (issue #577); this is not measured camera calibration; other raws and rejected fits use a neutral fallback (camera RGB ≈ linear sRGB, `matrix_is_fallback`) with as-shot white balance, so colours are muted and not accurate. Needs our own per-camera calibration: matrices the files carry themselves (e.g. Olympus `ColorMatrix`), fitting each camera to its own embedded JPEG, then chart shots. Adobe matrices / DCPs are never used. Biggest image-quality gap today | +| LR-PROF-CAMERACOLOR | Camera colour calibration (own) | P0 | 🟡 | `crates/raw/src/color.rs`, `crates/raw/src/profile.rs`, `crates/raw/src/gaintable.rs`, `crates/engine/src/camera_preview.rs` | DNG files use the colour matrices and the camera-profile look they carry (`ProfileHueSatMap`, `ProfileLookTable`, `ProfileToneCurve`, read from the file at run time per DNG spec ch. 6 — Lightroom-converted DNGs rendered flat and muted without them, issue #138). A DNG's `ProfileGainTableMap` / `ProfileGainTableMap2` (Apple ProRAW's local tone map; both versions, DNG 1.7 precedence, the file's byte order with a big-endian fallback) is read and written back by DNG export and not rendered by default, as Lightroom Classic renders ProRAW without it (measured on one CC0 iPhone 12 Pro ProRAW); the Profile option "Camera local tone mapping" (`profile.camera_local_tone`, per photo, off by default, `crates/pipeline/src/local_tone.rs`) renders it as the camera does, per output pixel in the scene-linear stage (CPU, also under the GPU path); Sony ARW, Nikon NEF, Panasonic RW2, Fujifilm RAF, Canon CR3 and CR2, Pentax PEF, Samsung SRW and Olympus ORF get a guarded file-local fit to their own embedded JPEG — chromaticity matrix + hue/saturation/value table + tone and chroma curves, relative WB — or, with a bundled or local per-model profile pooled from many photos (`lightcraft-cli calibrate`, ARW, NEF and RAF so far, `crates/engine/src/camera_profiles.rs`), the profile's colour and only their own tone/chroma curves (on 29 held-out ILCE-7M4 photos mean ΔE vs the camera JPEG 3.54 → 3.10; bundled ILCE-7CR from 125 photos: 26 held-out 4.07 → 3.29, and every one of the 131 photos accepted, 8 of which fell back to neutral without it), kept with smart previews (see docs/camera-preview-colour.md); Sony ARWs shot with DRO on (maker note `0xb025`, on by default) keep that colour but their tone curve is lowered to Sony's curve without DRO, whose lifted shadows are in the camera JPEG only (issue #244: 8 ILCE-7CR photos +6.4 → +0.8 L* from Lightroom's default, median ΔE 7.5 → 3.3); 52 models without a profile whose JPEG fit fails (or that have no usable JPEG) start from DNG-style matrices fitted to their measured spectral sensitivities instead of the neutral fallback (`crates/raw/src/spectral.rs`, rawtoaces-data v1.1.0, Apache-2.0, aliases included; not yet measured against the camera JPEG); ARW: on 10 public raw.pixls.us samples from 8 bodies 7 fits were accepted, mean ΔE vs the camera JPEG 17–26 → 3–10; NEF: 13 of 13 decodable samples (D750, D780, D850, D7500, Z 50 and local D7500 shots) accepted, ΔE 13–46 → 3–8 (issue #150); RW2 / RWL: 140 of 174 public samples accepted, from 93 of the 114 bodies with a preview, median ΔE 5.0 with matching lightness (13 of the 14 corpus files with a preview: ΔE 9.6–27 → 2.8–8.9; most rejections are compacts and kit zooms whose camera JPEG is distortion-corrected); a fit that fails the gates on all pixels is retried away from edges, where a lens-corrected camera JPEG still lines up (issue #232: the six distortion-corrected public ILCE-7RM2 samples ΔE 16.6–16.9 → 3.7–3.8, the corpus GX80 19.1 → 7.9); RAF: bundled X-H2S/X-T4 profiles from 201/545 photos; on 150 withheld files mean ΔE improves slightly over per-file fitting (X-H2S 1.70 → 1.62, X-T4 2.43 → 2.34); 23 of 24 references from 13 bodies accepted, including the dark X-H2S samples (8.74 → 2.25); ORF: the 3 decodable corpus files (E-1, E-400, XZ-2) accepted (`docs/camera-preview-colour.md`); a raw whose camera JPEG is black and white (a monochrome picture style) takes only the JPEG's tone curve, on the camera profile's, spectral or neutral colour (issue #577); the Profile panel reports the decoded starting-colour source, accepted built-in/local profile, partial fit and tone provenance (#1310); this is not measured camera calibration; other raws and rejected fits use a neutral fallback (camera RGB ≈ linear sRGB, `matrix_is_fallback`) with as-shot white balance, so colours are muted and not accurate. Needs our own per-camera calibration: matrices the files carry themselves (e.g. Olympus `ColorMatrix`), fitting each camera to its own embedded JPEG, then chart shots. Adobe matrices / DCPs are never used. Biggest image-quality gap today | | LR-PROF-CREATIVE | Creative profiles (own) | P2 | ✅ | `cmd:develop.profile`, `crates/pipeline/src/profiles.rs` | 16 own looks in Film / Cinematic / Muted / B&W (tone + point-curve fades, colour grading, mixer / B&W mix); scale with `ctl:profile.amount`; sliders untouched | | LR-PROF-LEGACY | Legacy profiles | P2 | ⬜ | | | | LR-PROF-NONRAW | Profiles for non-raw files | P0 | ✅ | `cmd:develop.profile` | same looks apply to JPEG/TIFF | @@ -787,6 +787,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | Date | Change | Summary | |---|---|---| +| 2026-10-12 | minor | #1310: Profile panel starting-colour provenance; calibration gap and readiness unchanged | | 2026-10-11 | minor | KEY-SLIDER-TYPE: honor immediate Return/Escape and keep typed keys in the value editor; add regression references | | 2026-10-11 | minor | LR-PROF-CAMERACOLOR: raws with a black-and-white camera JPEG take its tone curve (issue #577) | | 2026-10-11 | minor | LR-VIEW-ZOOM and LR-VIEW-COMPARE: Compare and Reference are sharp at 1:1 (zoom windows per pane, two originals kept decoded while they are open); statuses unchanged | From 467213a58e7cb630e9161266bcd96ff18fac85f7 Mon Sep 17 00:00:00 2001 From: QuirkyTurtle94 Date: Tue, 13 Oct 2026 09:46:50 +0100 Subject: [PATCH 3/3] Update crates/ui-egui/locales/pt-br-formats.json Co-authored-by: null 00000111 <287216888+s17sh70x2jfl031ag@users.noreply.github.com> --- crates/ui-egui/locales/pt-br-formats.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/locales/pt-br-formats.json b/crates/ui-egui/locales/pt-br-formats.json index 5269654be2d..27aa9b17db6 100644 --- a/crates/ui-egui/locales/pt-br-formats.json +++ b/crates/ui-egui/locales/pt-br-formats.json @@ -245,6 +245,6 @@ "{n} added to Apple Photos album “{album}”": "{n} adicionadas ao álbum “{album}” do Fotos da Apple", "{n} added to Apple Photos": "{n} adicionadas ao Fotos da Apple", "{n} photos opened for editing; each is stacked with its original": "{n} fotos abertas para edição; cada uma está empilhada com a original", - "Camera colour: {model} profile (local)": "Camera colour: {model} profile (local)", - "Camera colour: {model} profile (built in)": "Camera colour: {model} profile (built in)" + "Camera colour: {model} profile (local)": "Cor da câmera: perfil {model} (local)", + "Camera colour: {model} profile (built in)": "Cor da câmera: perfil {model} (integrado)" }