Skip to content

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

Merge PR #734

Claude33686e6951d0
diff --cc crates/engine/src/media.rs
index 344d0b0dd,f35056850..1d11f225c
--- a/crates/engine/src/media.rs
+++ b/crates/engine/src/media.rs
@@@ -62,7 -62,7 +62,7 @@@ impl SettingsHashes
}
/// Bump when the pipeline's output changes, to invalidate cached thumbnails.
- pub const RENDER_CACHE_VERSION: u64 = 58;
-pub const RENDER_CACHE_VERSION: u64 = 48;
++pub const RENDER_CACHE_VERSION: u64 = 59;
/// Thumbnails render at one of these long edges (so window/cell size changes reuse the cache).
pub const THUMB_SIZES: [usize; 4] = [128, 256, 384, 512];
diff --cc crates/raw/tests/corpus.rs
index b58bacdd0,d60aa6588..5ca4777b7
--- a/crates/raw/tests/corpus.rs
+++ b/crates/raw/tests/corpus.rs
@@@ -1018,46 -932,74 +1018,118 @@@ fn sony_embedded_distortion_is_limited_
eprintln!("Sony distortion model boundary: {checked} corpus files checked");
}
+/// Kodak DCS520C (`crates/raw/src/vendor/kodak.rs`): the two-component lossless JPEG strip decodes through the
+/// file's response curve to a 1736 x 1160 GRBG mosaic with 12-bit white, per-position black levels and the
+/// white balance of the vendor IFD. Looks for the corpus copy, then the raw.pixls.us folder; skips without either.
+#[test]
+fn corpus_kodak_dcs520c() {
+ let name = "2573_Kodak - DCS520C - 12bit (3_2).TIF";
+ let candidates = [corpus_root().join("raw").join("kodak-dcs520c.tif"), Path::new("P:/raw-pixls/Kodak/DCS520C").join(name)];
+ let Some(bytes) = candidates.iter().find_map(|p| std::fs::read(p).ok()) else {
+ eprintln!("skip: DCS520C sample absent");
+ return;
+ };
+ assert_eq!(probe(&bytes), Some(RawFormat::KodakDcs));
+ let img = decode(&bytes).unwrap_or_else(|e| panic!("{e}"));
+ assert_eq!((img.width, img.height, img.bits), (1736, 1160, 12));
+ assert_eq!(img.cfa.as_ref().map(|c| c.name()).as_deref(), Some("GRBG"));
+ assert_eq!(img.white_at(0), 4095.0);
+ let lightcraft_raw::RawData::U16(d) = &img.data else { panic!("float data") };
+ assert_eq!(d.len(), 1736 * 1160);
+ // stored 191..=622 expands to 191..=4095
+ assert_eq!((d.iter().min().copied(), d.iter().max().copied()), (Some(191), Some(4095)));
+ // black: G and R about 220, B about 197 (the darkest 0.01% of each position)
+ let b = &img.black.values;
+ assert_eq!(b.len(), 4);
+ assert!(
+ (200.0..=235.0).contains(&b[0]) && (200.0..=235.0).contains(&b[1]) && (185.0..=210.0).contains(&b[2]) && (200.0..=235.0).contains(&b[3]),
+ "{b:?}"
+ );
+ let wb = img.wb_multipliers.expect("white balance");
+ assert!((wb[0] - 0.9587).abs() < 1e-3 && wb[1] == 1.0 && (wb[2] - 1.9913).abs() < 1e-3, "{wb:?}");
+ // no column stripes: the two greens sit in different JPEG components (G1 on even columns, G2 on odd columns), so a component mismatch would split them
+ let mean = |y0: usize, x0: usize| {
+ let (mut s, mut n) = (0f64, 0f64);
+ for y in (y0..1160).step_by(2) {
+ for x in (x0..1736).step_by(2) {
+ s += f64::from(d[y * 1736 + x]);
+ n += 1.0;
+ }
+ }
+ s / n
+ };
+ let (g1, g2) = (mean(0, 0), mean(1, 1));
+ assert!((g1 - g2).abs() < 0.01 * g1, "greens {g1} vs {g2}");
+}
++
+ /// Fujifilm RAF lens tables (`0xf00b` distortion, `0xf010` vignetting) become a warp and a vignette gain for the
+ /// cameras whose geometry was checked against the camera JPEG (docs/fuji-lens-corrections.md). Reads `LIGHTCRAFT_FUJI` (a folder
+ /// of RAFs or of per-model folders, e.g. the CC0 pixls set) or the corpus' `raf-fuji-*` files; skips when absent.
+ #[test]
+ fn fuji_embedded_lens_tables_follow_the_validated_models() {
+ fn collect(dir: &Path, depth: usize, out: &mut Vec<PathBuf>) {
+ let Ok(rd) = std::fs::read_dir(dir) else { return };
+ for e in rd.flatten() {
+ let p = e.path();
+ if p.is_dir() && depth < 2 {
+ collect(&p, depth + 1, out);
+ } else if p.extension().is_some_and(|x| x.eq_ignore_ascii_case("raf")) {
+ out.push(p);
+ }
+ }
+ }
+ let mut files = Vec::new();
+ match std::env::var_os("LIGHTCRAFT_FUJI") {
+ Some(dir) => collect(Path::new(&dir), 0, &mut files),
+ None => {
+ collect(&corpus_root().join("raw"), 1, &mut files);
+ files.retain(|p| p.file_name().is_some_and(|n| n.to_string_lossy().starts_with("raf-fuji-")));
+ }
+ }
+ files.sort();
+ // Bodies whose tables did not match the camera JPEG (or have no usable geometry sample): never corrected.
+ let unvalidated = ["FinePix F550EXR", "FinePix S1", "FinePix SL1000", "X10", "XF1", "XQ1"];
+ let (mut warped, mut vignetted, mut checked) = (0, 0, 0);
+ for path in &files {
+ let Ok(bytes) = std::fs::read(path) else { continue };
+ if lightcraft_raw::probe(&bytes) != Some(RawFormat::Raf) {
+ continue;
+ }
+ let name = path.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
+ let Ok(full) = decode(&bytes) else { continue };
+ assert_eq!(probe_info(&bytes).unwrap(), full.info(), "{name}: header and full decode agree");
+ let model = full.metadata.model.clone().unwrap_or_default();
+ let ops = &full.opcodes.list3;
+ if unvalidated.contains(&model.as_str()) {
+ assert!(ops.is_empty(), "{name} ({model}) is not a validated model");
+ }
+ for op in ops {
+ match op {
+ lightcraft_raw::Opcode::WarpRectilinear { planes, center } => {
+ assert_eq!(*center, [0.5, 0.5], "{name}");
+ assert_eq!(planes.len(), 1, "{name}: lateral CA is not applied");
+ // a sane radial mapping: close to 1 at the centre, monotone, never folding
+ let k = planes[0];
+ assert!((0.85..1.15).contains(&k[0]), "{name}: {k:?}");
+ let source = |r: f64| r * (k[0] + r * r * (k[1] + r * r * (k[2] + r * r * k[3])));
+ assert!((0..100).all(|i| source((i + 1) as f64 / 100.0) > source(i as f64 / 100.0)), "{name}");
+ warped += 1;
+ }
+ lightcraft_raw::Opcode::FixVignetteRadial { k, center } => {
+ assert_eq!(*center, [0.5, 0.5], "{name}");
+ let gain = 1.0 + k.iter().enumerate().map(|(i, c)| c * 1.0f64.powi(2 * i as i32 + 2)).sum::<f64>();
+ assert!((1.0..3.0).contains(&gain), "{name}: corner gain {gain}");
+ vignetted += 1;
+ }
+ other => panic!("{name}: unexpected opcode {other:?}"),
+ }
+ }
+ eprintln!(
+ "{model}: {} opcode(s) {}",
+ ops.len(),
+ if ops.iter().any(|o| matches!(o, lightcraft_raw::Opcode::WarpRectilinear { .. })) { "warp" } else { "no warp" }
+ );
+ checked += 1;
+ }
+ eprintln!("Fuji lens tables: {checked} RAFs, {warped} warps, {vignetted} vignette gains");
+ }
diff --cc docs/parity-checklist.md
index febb9723a,6456552a5..e1e39d0b1
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@@ -210,7 -277,7 +210,7 @@@ differences and missing bindings are i
| LR-EDIT-DETAIL-SUPERRES | Super resolution | P2 | ⬜ | | |
| LR-EDIT-DETAIL-AISHARPEN | AI sharpen | OOS | 🚫 | | |
| LR-EDIT-OPTICS-CA | Remove chromatic aberration | P1 | ✅ | `crates/ui-egui/src/panels/edit.rs` (checkbox), `ctl:optics.caRed`, `ctl:optics.caBlue` | |
- | LR-EDIT-OPTICS-PROFILE | Lens profile corrections | P1 | 🟡 | `ctl:optics.profileDistortion`, `ctl:optics.profileVignetting`, `crates/pipeline/src/optics.rs`, `crates/raw/src/vendor/rw2.rs`, `crates/engine/src/crs.rs` | uses corrections embedded in the file: DNG `WarpRectilinear` / `WarpRectilinear2` (opcode 14, DNG 1.6: degree-14 radial polynomial, valid-radius clamp, reciprocal option, applied in list order with the spec's skip rule for a `WarpRectilinear` after an optional one, so Pixel DNGs' two-stage warp is corrected; up to 3 chained stages, sampled on the CPU because the polynomials need `f64`; issue #635) / `FixVignetteRadial`, and the camera's own distortion correction in Panasonic / Leica RW2 / RWL files (tag `0x0119`, read as the equivalent `WarpRectilinear`; on 79 photos from 13 bodies and 11 lenses the corrected render lines up with the camera JPEG within 0.75 px at 1440 px at the corners, from up to 13 % of the half diagonal uncorrected; issue #256); an imported preset's `LensProfileEnable=0` leaves them on, as Lightroom applies built-in corrections regardless (inferred); Sony ILCE-7RM4A Bayer ARW raw-IFD distortion tables (`0x7037`, 16-sample layout, native 3:2 framing) use the same warp path, enabled only for the independently validated ILCE-7RM4A with FE 24–105 and FE 200–600 lenses; other Sony models remain uncorrected (see `docs/sony-lens-corrections.md`); vignetting and lateral CA data of other raw formats (Olympus, Fujifilm, Sony) not read yet; Reload from Disk reads the file's lens data for photos catalogued without it and turns the correction on for those still at import settings (issue #314); lens-profile database: a lensfun-format XML database in `LIGHTCRAFT_LENSFUN_DIR` (none is bundled) supplies distortion (poly3 / poly5 / PTLens), TCA and vignetting for lenses it lists (`crates/lensdb`, `crates/engine/src/lens_profiles.rs`, `docs/lens-profiles.md`); no settings switch or bundled database yet |
-| LR-EDIT-OPTICS-PROFILE | Lens profile corrections | P1 | 🟡 | `ctl:optics.profileDistortion`, `ctl:optics.profileVignetting`, `crates/pipeline/src/optics.rs`, `crates/raw/src/vendor/rw2.rs`, `crates/raw/src/vendor/raf_lens.rs`, `crates/engine/src/crs.rs` | uses corrections embedded in the file: DNG `WarpRectilinear` / `FixVignetteRadial`, and the camera's own distortion correction in Panasonic / Leica RW2 / RWL files (tag `0x0119`, read as the equivalent `WarpRectilinear`; on 79 photos from 13 bodies and 11 lenses the corrected render lines up with the camera JPEG within 0.75 px at 1440 px at the corners, from up to 13 % of the half diagonal uncorrected; issue #256); an imported preset's `LensProfileEnable=0` leaves them on, as Lightroom applies built-in corrections regardless (inferred); Sony ILCE-7RM4A Bayer ARW raw-IFD distortion tables (`0x7037`, 16-sample layout, native 3:2 framing) use the same warp path, enabled only for the independently validated ILCE-7RM4A with FE 24–105 and FE 200–600 lenses; other Sony models remain uncorrected (see `docs/sony-lens-corrections.md`); Fujifilm RAF raw-IFD tables (`0xf00b` distortion, `0xf010` vignetting; `crates/raw/src/vendor/raf_lens.rs`, `docs/fuji-lens-corrections.md`) become a `WarpRectilinear` with the camera's frame-filling zoom and a `FixVignetteRadial` gain for 59 body models with sample files checked against the camera JPEG (the table indexed by the source radius with last knot at the corner; on 67 body/lens combinations the corrected render's radial shape error against the camera JPEG falls from a median of 0.72 % to 0.05 % of the half diagonal, largest 0.42 %, and the vignetting gain of the JPEG tracks the table at a median correlation of 0.987); files whose table scale is not the recorded image's half diagonal (X-S20, X-T30 III, X-M5, X-T5 crops) and six unmatched bodies stay uncorrected; Fujifilm's lateral CA table (`0xf00f`) is real but is not applied, because our demosaic already registers the planes and the stored shift over-corrects; vignetting and lateral CA data of Olympus and Sony raws not read yet; Reload from Disk reads the file's lens data for photos catalogued without it and turns the correction on for those still at import settings (issue #314); no lens-profile database |
++| LR-EDIT-OPTICS-PROFILE | Lens profile corrections | P1 | 🟡 | `ctl:optics.profileDistortion`, `ctl:optics.profileVignetting`, `crates/pipeline/src/optics.rs`, `crates/raw/src/vendor/rw2.rs`, `crates/raw/src/vendor/raf_lens.rs`, `crates/engine/src/crs.rs` | uses corrections embedded in the file: DNG `WarpRectilinear` / `WarpRectilinear2` (opcode 14, DNG 1.6: degree-14 radial polynomial, valid-radius clamp, reciprocal option, applied in list order with the spec's skip rule for a `WarpRectilinear` after an optional one, so Pixel DNGs' two-stage warp is corrected; up to 3 chained stages, sampled on the CPU because the polynomials need `f64`; issue #635) / `FixVignetteRadial`, and the camera's own distortion correction in Panasonic / Leica RW2 / RWL files (tag `0x0119`, read as the equivalent `WarpRectilinear`; on 79 photos from 13 bodies and 11 lenses the corrected render lines up with the camera JPEG within 0.75 px at 1440 px at the corners, from up to 13 % of the half diagonal uncorrected; issue #256); an imported preset's `LensProfileEnable=0` leaves them on, as Lightroom applies built-in corrections regardless (inferred); Sony ILCE-7RM4A Bayer ARW raw-IFD distortion tables (`0x7037`, 16-sample layout, native 3:2 framing) use the same warp path, enabled only for the independently validated ILCE-7RM4A with FE 24–105 and FE 200–600 lenses; other Sony models remain uncorrected (see `docs/sony-lens-corrections.md`); Fujifilm RAF raw-IFD tables (`0xf00b` distortion, `0xf010` vignetting; `crates/raw/src/vendor/raf_lens.rs`, `docs/fuji-lens-corrections.md`) become a `WarpRectilinear` with the camera's frame-filling zoom and a `FixVignetteRadial` gain for 59 body models with sample files checked against the camera JPEG (the table indexed by the source radius with last knot at the corner; on 67 body/lens combinations the corrected render's radial shape error against the camera JPEG falls from a median of 0.72 % to 0.05 % of the half diagonal, largest 0.42 %, and the vignetting gain of the JPEG tracks the table at a median correlation of 0.987); files whose table scale is not the recorded image's half diagonal (X-S20, X-T30 III, X-M5, X-T5 crops) and six unmatched bodies stay uncorrected; Fujifilm's lateral CA table (`0xf00f`) is real but is not applied, because our demosaic already registers the planes and the stored shift over-corrects; vignetting and lateral CA data of Olympus and Sony raws not read yet; Reload from Disk reads the file's lens data for photos catalogued without it and turns the correction on for those still at import settings (issue #314); lens-profile database: a lensfun-format XML database in `LIGHTCRAFT_LENSFUN_DIR` (none is bundled) supplies distortion (poly3 / poly5 / PTLens), TCA and vignetting for lenses it lists (`crates/lensdb`, `crates/engine/src/lens_profiles.rs`, `docs/lens-profiles.md`); no settings switch or bundled database yet |
)
| LR-EDIT-OPTICS-DEFRINGE | Defringe | P1 | ✅ | `ctl:optics.defringe*` | no fringe eyedropper |
| LR-EDIT-OPTICS-MANUAL | Manual distortion / vignetting | P1 | ✅ | `ctl:optics.distortion`, `ctl:optics.vignetting`, `ctl:optics.vignettingMidpoint` | |
diff --cc docs/whats-new.md
index 034da5c05,d98e86fee..e970dc25f
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@@ -1,59 -1,13 +1,65 @@@
# What's new in LightCraft
-## October 2026
+## 2026-10-11
+
+### Open Library knows a Lightroom catalog
+- Choosing a Lightroom Classic catalog folder in File → Open Library… (or one of its `Previews.lrdata` /
+ `.lrcat-data` folders, or the `.lrcat`) no longer makes an empty LightCraft library inside it (issue #891). The
+ library open now stays, and LightCraft says "This is a Lightroom catalog, not a LightCraft library" and offers
+ **Import Lightroom Catalog…** with that catalog, or Cancel. `lightcraft-cli --library` refuses those folders too.
+
+### Canon EOS R5 Mark II
+- Canon EOS R5 Mark II C-RAW files that opened as "preview only" (more than half of them, depending on the
+ scene) now develop from their sensor data with every editing tool, like the camera's other raws. Photos
+ imported earlier switch over with Photo ▸ Reload from Disk.
+
+## 2026-10-10
+
+### Dialogs fit the window
+- A dialog taller than the window no longer runs off it (issue #781): on a 1366×768 screen the Export dialog's title
+ and its Cancel / OK buttons were off screen, so it couldn't be confirmed. Now its options scroll and the title and
+ buttons stay visible. Long lists in dialogs (What's New, All Metadata, Keyboard Shortcuts) get shorter to fit.
+ Dialogs that fit look as before.
+
+### Previews match exports on Mac screens
+- On macOS, photos are shown through the profile of the screen the window is on while no monitor profile is chosen in
+ Settings ▸ Display (issue #787). On P3 screens previews used to look more saturated than the exported files in
+ Preview or Photos. Moving the window to another screen is followed; **Use Screen Profile** goes back to it after
+ choosing a profile file.
+
+### Sidebar sections
+- Arrange the left sidebar your way: drag Albums, Local, By Date, Folders or Keywords by its header to move it (a line
+ shows where it will go), or right-click a header for Move Up / Move Down.
+- Hide the sections you don't use: View ▸ Sidebar Sections, or right-click a header ▸ Hide This Section. Right-click
+ the My Photos title to bring one back, or choose Reset Sidebar Sections. The arrangement is remembered.
+- In a long section, the header stays at the top of the sidebar while you scroll through its rows, so you always see
+ which section you are in and can fold it from there.
+- Sections are easier to tell apart: a hairline between them, the fold chevron in the same column as the rows'
+ triangles, a highlight under the pointer. A folded section shows how many rows it holds, counts of 0 are fainter,
+ and a section with nothing in it says so instead of disappearing.
+- Recently Deleted is listed with All Photos, Recently Added and Picks under My Photos.
+- Keywords has a + in its header, like Albums: Create Keyword Tag without opening the Keyword List.
+- Agents: `view.sidebarSection`, `view.sidebarMoveSection`, `view.sidebarReset`; `ui.set` takes `sidebar`.
+
+### Kelvin white balance for raws whose camera has colour matrices
+- Raws from the 52 camera models whose colour matrices LightCraft has measured (Sony ILCE-7M3, ILCE-7M4, ILCE-7RM3,
+ Nikon D850, Canon EOS 5D Mark III and others) now show white balance in Kelvin, as a DNG does and as Lightroom
+ does: As Shot reads the file's white (an ILCE-7M3 sample: 4268 K / +7), the Temp slider runs 2000–50000 K and the
+ Daylight, Cloudy, Shade, Tungsten, Fluorescent and Flash presets set real temperatures (issue #730). The matrices
+ only convert between the camera's multipliers and Kelvin; the colour look is what it was.
+- Nothing already edited changes: a Custom white balance set on the old relative scale renders pixel for pixel as
+ before, and becomes the Kelvin value with the same look the next time it is edited. A photo imported earlier shows
+ its real As Shot temperature once the file is opened (or Reload reads it).
+- Lightroom's `crs:Temperature` for these raws is read as the Kelvin it is (sidecars, Lightroom catalogs, presets);
+ raws of other cameras keep the as-shot shift of issue #510. The two Kelvin scales come from different matrices and
+ differ by about 7–10 % on the ILCE-7M3; which one is off is still open.
+ ### Fujifilm lens corrections
+ - Fujifilm RAFs from 59 camera models now get the lens correction the camera stores in the file: distortion (with the
+ camera's own zoom to fill the frame) and vignetting, as with Panasonic and Sony files. The Optics profile controls
+ adjust or switch them off, and DNG export keeps them. Lateral chromatic aberration data is not applied: our
+ demosaic already lines the colour planes up. Details and measurements: `docs/fuji-lens-corrections.md`.
+
### Activity stack
- Long-running tasks show in one place, top left under the top bar, as in Lightroom Classic (issue #345): imports and
folder scans, exports (and the contact sheet PDF), Synchronize Folder, Build / Smart Previews, Lightroom catalog import, Photo Merge, model downloads, the face scan,