LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge PR #646 (HDR peak threaded through #533's base_tone; V1 at peak 1 unchanged)
Brandon Thomase46e7ab2657a
diff --cc README.mdindex 450d9740e,98491ad10..217092fbf--- a/README.md+++ b/README.md@@@ -304,10 -289,10 +304,10 @@@ LightCraft is young and moving fast. **- **As a day-to-day Lightroom replacement we're nearer 60–70%.** It's great for JPEG/DNG and most Nikon / Sony /older-Canon raws on one machine.- **The biggest gaps:**- - **camera colour calibration:** Sony, Nikon, Panasonic, Fujifilm and Canon CR3 raws have guarded estimates from their camera JPEGs, with built-in ILCE-7M4, X-H2S and X-T4 profiles; measured calibration is missing, and other raws or rejected fits retain a neutral matrix;+ - **camera colour calibration:** Sony, Nikon, Panasonic, Fujifilm and Canon CR3 raws have guarded estimates from their camera JPEGs, with built-in ILCE-7CR, ILCE-7M4, X-H2S and X-T4 profiles; measured calibration is missing, and other raws or rejected fits retain a neutral matrix;- **compressed Olympus raws and unsupported CR3 variants:** these use embedded JPEG previews when present. Fujifilm lossless/lossy compressed RAF now decodes sensor data; [verification and existing-library reload instructions](docs/raf-compression.md);- **AI masks and denoise:** subject and sky selection are classical heuristics;- - **HDR, video and the Classic Print / Book / Map modules.**+ - **on-screen HDR display, video and the Classic Print / Book / Map modules.**- **What's next:** see [where we're going](ROADMAP.md#where-were-going).| Area | Status |diff --cc ROADMAP.mdindex 12b273a18,662f9c519..dad5a432d--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -23,13 -23,13 +23,13 @@@ duplicate Local entries #22, black GPU| Dimension | Estimate | What's true today | Biggest gaps ||---|---:|---|---|| **Feature checklist** | 79.7% | P0 core and P1 nearly complete: import (Add / Copy / Move, templates, devices), library, grid/loupe/compare/survey, every Edit slider, curves, colour grading, masking tools, crop/Upright, heal/clone, presets/profiles, versions/history, sync, export, menus, shortcuts | P0: full-resolution zoom detail; P1: lens-profile database, content-aware fill (patch synthesis), video playback/trim |-| **RAW coverage** (formats people shoot) | ~55% | DNG (all kinds), CR2, CR3 lossless Bayer and version 0x100/0x200 C-RAW (M50/R100/R8 pixel-exact corpus), ARW, NEF (uncompressed + Huffman lossless/lossy), RAF (uncompressed, lossless/lossy compressed Bayer and X-Trans), uncompressed ORF, uncompressed Samsung SRW (NX5 to NX1100, EX1, WB2000), RW2 / RWL / Panasonic RAW (every raw format, checked on 178 files from 118 Panasonic and Leica bodies), PEF; every container's embedded preview (incl. CR3) | **CR3** (every Canon since ~2018), compressed ORF, compressed Samsung SRW (NX1, NX30, NX300, NX500, NX2000, NX3000, NX3300, NX mini), Nikon lossy-after-split, Canon sRAW, HEIC/AVIF. NEFs labelled compressed but stored uncompressed (Z 6 packed 14-bit, D850 12-bit uncompressed). Per-model verification is thin (~55 corpus files vs >1,000 models) |-| **Colour & image quality** | ~55–65% | Pipeline is complete and fast; GPU path CPU-exact within 1/255 | **No measured camera calibration database**: ARW, NEF, RW2, RAF, CR3, CR2 and PEF have guarded camera-JPEG colour estimates, with bundled ILCE-7M4, X-H2S and X-T4 profiles (docs/camera-preview-colour.md); other non-DNG raws and rejected estimates use a neutral matrix. Colour fidelity remains incomplete. No lens-profile database. No measured fidelity against Lightroom (tone, highlights, texture/clarity, NR, sharpening are tuned by eye) |+| **RAW coverage** (formats people shoot) | ~55% | DNG (all kinds), CR2, CR3 lossless Bayer and version 0x100/0x200 C-RAW (M50/R100/R8 pixel-exact corpus), ARW, NEF (uncompressed + Huffman lossless/lossy), RAF (uncompressed, lossless/lossy compressed Bayer and X-Trans), uncompressed ORF, uncompressed Samsung SRW (NX5 to NX1100, EX1, WB2000), RW2 / RWL / Panasonic RAW (every raw format, checked on 178 files from 118 Panasonic and Leica bodies), PEF; every container's embedded preview (incl. CR3) | **CR3** (every Canon since ~2018), compressed ORF, compressed Samsung SRW (NX1, NX30, NX300, NX500, NX2000, NX3000, NX3300, NX mini), Nikon lossy-after-split, Canon sRAW, HEIC/AVIF. NEFs labelled compressed but stored uncompressed (Z 6 packed 14-bit, D850 12-bit uncompressed). Nikon High Efficiency NEF (HE / HE★: Z 8, Z 9, Z 6III, Z f; JPEG XS-based, preview only, #193). Per-model verification is thin (~55 corpus files vs >1,000 models) |+| **Colour & image quality** | ~55–65% | Pipeline is complete and fast; GPU path CPU-exact within 1/255 | **No measured camera calibration database**: ARW, NEF, RW2, RAF, CR3, CR2 and PEF have guarded camera-JPEG colour estimates, with bundled ILCE-7CR, ILCE-7M4, X-H2S and X-T4 profiles (docs/camera-preview-colour.md); other non-DNG raws and rejected estimates use a neutral matrix. Colour fidelity remains incomplete. No lens-profile database. No measured fidelity against Lightroom (tone, highlights, texture/clarity, NR, sharpening are tuned by eye) || **AI & computational** | ~15–20% | Assisted culling (focus, bursts), auto tone, HDR/panorama merge; subject/sky/background masks as classical heuristics, or the photo's own segmentation mattes when it ships them (DNG semantic masks, e.g. iPhone ProRAW's sky matte); non-destructive Bayer RAW denoise with opt-in weights on pure-Rust CPU/GPU; **faces (MVP, [docs/faces.md](docs/faces.md))**: a pure-Rust detector (a 232 KB opt-in download), opt-in recognition models (one-click download or add a file; they run on the shared pure-Rust CPU interpreter; pinned SFace/AuraFace embeddings agree with an independent reference runtime on 40 public crops; one-thread medians 34–36 / 233–252 ms (AuraFace remains expensive)), a background scan that finds and embeds faces, name suggestions, a person's page with look-alike faces to confirm, an Unnamed faces section (look-alikes together, select a group and name it at once) | Real segmentation masks (subject, sky, people, objects, landscape, depth), denoise model policy / linear RGB / quality verification, super resolution, lens blur, generative remove, natural-language search; for faces: clusters with separators between groups, small faces in large photos (the detector looks at 640 px), thresholds calibrated on live faces, writing face regions back to XMP. **Blocked on a model strategy** (licensable weights or our own training; pure-Rust inference is feasible) || **Workflow & library** | ~85% (single machine) | Robust catalog (journal + snapshots, background compaction, crash-tested), 85k-photo libraries stay responsive, Local browsing with automatic cleanup, XMP interop, keywords, smart albums, Move import | Opening an 85k library takes 1.7–4.7 s; no cloud sync (out of scope), no tablet companion (#74, roadmap), shared albums, publish services, tethering |-| **Classic modules** | ~30% | Geotagging from GPX track logs, soft proofing (partial), slideshow (basic) | **Map view, Book, Print, Slideshow module, Web, publish services**: ~40 tracker rows ⬜ |+| **Classic modules** | ~30% | Geotagging from GPX track logs, soft proofing (partial), slideshow (basic), paginated contact-sheet PDF export (A4/Letter, layout/captions, current edits, 150 dpi sRGB) | **Map view, Book, full Print module, Slideshow module, Web, publish services**: contact sheets work, custom print packages and printer colour management remain missing |- | **HDR & video** | 0% | | HDR edit/display/export; video play/trim/edit/export |+ | **HDR & video** | ~25% | HDR editing (headroom limit, SDR rendition, Visualize HDR); gain map JPEG, PQ AVIF and float TIFF export | On-screen HDR display, HLG, HDR settings from crs XMP; video play/trim/edit/export |-| **Platform & robustness** | ~70% | macOS native; Windows/Linux builds; web via WASM; no-panic lints workspace-wide, `unsafe` confined to `crates/sysmem`; failed saves are reported; GPU errors fall back to CPU | Windows installer UI unverified on Windows (PR #79); GPU path proven only on Apple + user reports; English, Simplified/Traditional Chinese, Japanese, Brazilian Portuguese and German UI (see docs/localization.md); remaining technical errors; Traditional Chinese uses the Simplified Chinese font until craft-fonts has a TC face; accessibility partial; headless UI tests time out under machine load |+| **Platform & robustness** | ~70% | macOS native; Windows/Linux builds; web via WASM; no-panic lints workspace-wide, `unsafe` confined to `crates/sysmem`; failed saves are reported; GPU errors fall back to CPU | Windows installer UI unverified on Windows (PR #79); GPU path proven only on Apple + user reports; English, Simplified/Traditional Chinese, Japanese, Brazilian Portuguese, Spanish, German, Russian and Ukrainian UI (see docs/localization.md); remaining technical errors; Traditional Chinese uses the Simplified Chinese font until craft-fonts has a TC face; accessibility partial; headless UI tests time out under machine load |### By kind of userdiff --cc crates/codecs/README.mdindex a4fecef62,7c032566d..e1998c49d--- a/crates/codecs/README.md+++ b/crates/codecs/README.md@@@ -46,8 -52,9 +52,9 @@@ CRW, MRW, X3F) are detected so the engi| GIF / BMP | yes (first GIF frame) | — | via `image` || PSD / PSB | merged composite: 8/16/32-bit gray, RGB, CMYK, indexed, duotone (as gray); raw/RLE | — | ICC (1039), EXIF (1058), XMP (1060); ZIP-compressed composite, Lab and 1-bit unsupported || JPEG XL | yes (jxl-oxide, feature `jxl`, default on) | — | enum colour → rendered straight to linear Rec.2020; ICC → our ICC path; orientation applied by the decoder (reported as 1) |- | AVIF | **no** | yes (ravif/rav1e, native only, feature `avif`) | 8-bit sRGB, EXIF; no ICC in the muxer |+ | AVIF | **no** | yes (ravif/rav1e, native only, feature `avif`) | 8/10-bit sRGB, EXIF; no ICC in the muxer. HDR: `encode_avif_pq` writes 10-bit BT.2020 PQ (SDR white at 203 cd/m², CICP `nclx` + `clli`) |-| HEIC/HEIF | **no** (sniff only) | — | see gaps |+| HEIC/HEIF | yes with feature `heif` (lightcraft-heif: heic-rs + libheif-matching colour; 4:2:0/mono, 8–10-bit, grids, irot/imir/clap, ICC/nclx/VUI, EXIF/XMP, thumbnail item) | — | 4:2:2/4:4:4 (Canon/Sony HIF) unsupported |+ | Gain map JPEG (HDR) | gain map found and decoded (`gainmap::read_jpeg`): ISO 21496-1 metadata, else Adobe `hdrgm` XMP | yes (`gainmap::encode_jpeg`) | CIPA DC-007 MPF index (gain map typed `0x050000`), ISO 21496-1 APP2 on both images, `hdrgm` + Container XMP for Android/Chrome, Apple `HDRGainMap`/`HDRToneMap` XMP; gain maps are never used as thumbnails |## Colourdiff --cc crates/codecs/src/lib.rsindex 585505f99,ce93932aa..657987189--- a/crates/codecs/src/lib.rs+++ b/crates/codecs/src/lib.rs@@@ -17,9 -17,9 +17,10 @@@#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]mod convert;+pub mod display;pub mod encode;pub mod exif;+ pub mod gainmap;mod heif;pub mod icc;mod jpeg;diff --cc crates/engine/src/export.rsindex 8ee7f9ac9,60600b8e1..6a9e9147c--- a/crates/engine/src/export.rs+++ b/crates/engine/src/export.rs@@@ -1369,13 -1438,21 +1434,23 @@@ fn prepare_guarded) -> Result<PreparedExport, String> {let p = session.catalog.photo(id).ok_or("no such photo")?;let file_name = o.file_name_for(p, seq);+ // HDR output only for photos edited in HDR; the rest of the batch exports as usual+ let sdr_opts;+ let o = if o.hdr && !p.develop.hdr.enabled {+ sdr_opts = ExportOptions { hdr: false, ..o.clone() };+ &sdr_opts+ } else {+ o+ };- let work = if o.format.is_rendered() {+ let (full_px, long) = ((p.width as usize).saturating_mul(p.height as usize), p.width.max(p.height) as usize);+ let (work, weight) = if o.format.is_rendered() {let (w, h) = output_size(p, o);- let meta = export_metadata(p, o);+ let meta = export_metadata(p, &session.catalog, o);+ let gain_map = o.hdr_output() && o.format == ExportFormat::Jpeg;let job = session.export_job(id, w, h, o.effective_space(), o.effective_depth())?;+ let weight = render_weight(full_px, long, job.level, w.saturating_mul(h));- (Work::Render(Box::new(RenderWork { job, meta, opts: o.clone() })), weight)+ let hdr_job = if gain_map { Some(session.export_job(id, w, h, o.effective_space(), OutputDepth::F32Hdr)?) } else { None };- Work::Render(Box::new(RenderWork { job, hdr_job, meta, opts: o.clone() }))++ (Work::Render(Box::new(RenderWork { job, hdr_job, meta, opts: o.clone() })), weight)} else {let lightcraft_catalog::Source::File { path } = &p.source else {return Err(format!("{} is a generated demo photo: it has no original file to export", p.file_name));diff --cc crates/pipeline/src/finish.rsindex 1831126cc,76e6c1f6f..fce3b8324--- a/crates/pipeline/src/finish.rs+++ b/crates/pipeline/src/finish.rs@@@ -220,10 -223,19 +223,12 @@@ impl FinishParams((s.grain.amount / 100.0) as f32 * 0.13, cell.max(0.6), (s.grain.roughness / 100.0) as f32, s.grain.seed)});let calibration = s.section_enabled("calibration");+ let peak = s.hdr.peak();FinishParams {+ peak,calib: if calibration { crate::colorops::calibration_matrix(&s.calibration) } else { None },shadow_tint: if calibration { (s.calibration.shadows_tint / 100.0) as f32 } else { 0.0 },- tone: base_tone(s, info),- tone: if let Some(curve) = info.camera_tone.as_ref().filter(|_| info.raw && peak <= 1.0) {- // the camera's look is bounded at white: HDR renders use the HDR tone map- ToneMap::camera(curve, s.light.contrast, s.light.whites, s.light.blacks)- } else if info.raw {- ToneMap::hdr(s.light.contrast, s.light.whites, s.light.blacks, peak)- } else {- ToneMap::display_hdr(s.light.contrast, s.light.whites, s.light.blacks, peak)- },++ tone: base_tone(s, info, peak),lut: crate::lut::get(&s.profile.id).map(|l| (l, (s.profile.amount / 100.0).clamp(0.0, 2.0) as f32)),ops: ColorOps::new(s),curves: curve_luts(&s.curve),@@@ -254,41 -266,9 +259,43 @@@view: frame.view.map_or([0.0, 0.0, w as f32, h as f32], |v| [v.x as f32, v.y as f32, v.full_w as f32, v.full_h as f32]),}}++ /// Render into a display's primaries (sRGB curve) instead of the output space, soft proof+ /// included (see [`crate::DisplaySpace`]).+ pub fn for_display(&mut self, d: &crate::DisplaySpace, proof: Option<crate::Proof>) {+ self.to_out = d.from_working;+ self.out_luma = d.luma;+ self.out_trc = OutputTrc::Srgb;+ self.proof = proof.map(|pr| pr.params_display(d));+ }+}++/// The base tone map (scene → display luminance, with Contrast, Whites and Blacks) of `s`'s+/// rendering process. This is where a new tone model branches: a retuned default tone curve (issue+/// #146) is a new [`Process`] with its own arm here, and V1's arm stays as it is, so photos edited+/// under V1 keep their look (`docs/process-versions.md`). CPU and GPU both take it from here.- pub fn base_tone(s: &DevelopSettings, info: &SourceInfo) -> ToneMap {++/// `peak` is the HDR render's peak relative to SDR white ([`lightcraft_develop::Hdr::peak`]); at 1.0 (SDR)++/// every arm is the SDR tone map. The camera's look is bounded at white, so HDR renders use the HDR tone map.++pub fn base_tone(s: &DevelopSettings, info: &SourceInfo, peak: f32) -> ToneMap {+ let l = &s.light;+ match s.process.process() {- Process::V1 => match info.camera_tone.as_ref().filter(|_| info.raw) {++ Process::V1 => match info.camera_tone.as_ref().filter(|_| info.raw && peak <= 1.0) {+ Some(curve) => ToneMap::camera(curve, l.contrast, l.whites, l.blacks),- None if info.raw => ToneMap::new(l.contrast, l.whites, l.blacks),- None => ToneMap::display(l.contrast, l.whites, l.blacks),++ None if info.raw => ToneMap::hdr(l.contrast, l.whites, l.blacks, peak),++ None => ToneMap::display_hdr(l.contrast, l.whites, l.blacks, peak),+ },+ }}-pub(crate) fn finish(p: &Prepared, s: &DevelopSettings, frame: &Frame, info: &SourceInfo, space: OutputSpace, proof: Option<crate::Proof>) -> Rgba8 {+pub(crate) fn finish(+ p: &Prepared,+ s: &DevelopSettings,+ frame: &Frame,+ info: &SourceInfo,+ space: OutputSpace,+ display: Option<&crate::DisplaySpace>,+ proof: Option<crate::Proof>,+) -> Rgba8 {let (w, h) = (p.img.width, p.img.height);let mut fp = FinishParams::new(s, frame, info, w, h, p.px_per_long, p.air, space);fp.proof = proof.map(|pr| pr.params(space));diff --cc docs/parity.mdindex d851413f0,8291675b6..3d09ef1a8--- a/docs/parity.md+++ b/docs/parity.md@@@ -37,14 -37,14 +37,14 @@@ and prints the summary; `cargo xtask pa| N. Copy / paste / sync (SYNC) | 5 | 0 | 0 | 0 | 3/3 (100%) | 1/1 (100%) || O. Merge (MERGE) | 4 | 0 | 0 | 0 | — | — || P. Enhance (ENH) | 0 | 0 | 2 | 0 | — | — |- | Q. HDR (HDR) | 0 | 0 | 5 | 0 | — | — |+ | Q. HDR (HDR) | 2 | 3 | 0 | 0 | — | — || R. Video (VID) | 0 | 0 | 5 | 1 | — | 0/2 (0%) |- | S. Export (EXP) | 15 | 1 | 2 | 0 | 7/7 (100%) | 7/7 (100%) |+ | S. Export (EXP) | 15 | 2 | 1 | 0 | 7/7 (100%) | 7/7 (100%) || T. Share (SHARE) | 0 | 0 | 0 | 4 | — | — || U. Map & location (MAP) | 0 | 1 | 1 | 0 | — | 0/1 (0%) |-| V. Preferences (PREF) | 6 | 1 | 2 | 2 | 1/1 (100%) | 4/4 (100%) |+| V. Preferences (PREF) | 7 | 1 | 2 | 2 | 1/1 (100%) | 5/5 (100%) || W. Cloud & AI infrastructure (CLOUD / AI) | 1 | 0 | 1 | 2 | — | — |-| X. Cross-cutting behaviours (BEHAV) | 18 | 5 | 1 | 1 | 8/8 (100%) | 6/8 (75%) |+| X. Cross-cutting behaviours (BEHAV) | 18 | 6 | 1 | 1 | 8/8 (100%) | 6/9 (67%) || Y. Menus | 82 | 0 | 4 | 8 | 47/47 (100%) | 23/23 (100%) || Z. Keyboard shortcuts (desktop) | 75 | 3 | 3 | 1 | 49/52 (94%) | 23/24 (96%) || Lightroom Classic extras | 32 | 11 | 39 | 9 | — | 22/24 (92%) |@@@ -237,12 -236,12 +237,12 @@@ under the UI command that wraps it (a n| Id | Feature | Tier | Status | Evidence | Missing / notes ||---|---|---|---|---|---|-| LR-EDIT-AUTO | Auto settings | P0 | ✅ | `cmd:develop.auto`, `crates/pipeline/src/auto.rs` | |+| LR-EDIT-AUTO | Auto settings | P0 | ✅ | `cmd:develop.auto`, `crates/pipeline/src/auto.rs` | a Lightroom-like recipe calibrated black-box on Lightroom's Auto results for 24 Sony raws: Exposure from the scene's scene-linear log-average luminance (Lightroom's observed slope, -0.41 EV per EV), Highlights -66 and Shadows +52 (Lightroom's average Auto values), Contrast +68 and Vibrance +30 fitted on our scales. Held out one photo at a time: on the 16 photos whose start Sony's DRO doesn't brighten, a median dE76 of 6.4 from Lightroom's Auto results against 8.3 unedited; on all 24, 7.7 against 7.9 (issues #318, #209). Calibrated on Sony files only; Whites and Blacks stay 0 || LR-EDIT-BW | Black & white | P0 | ✅ | `cmd:develop.treatment` | |- | LR-EDIT-HDR-MODE | HDR editing | P2 | ⬜ | | |+ | LR-EDIT-HDR-MODE | HDR editing | P2 | ✅ | `cmd:develop.hdr`, `ctl:hdr.maxEv`, `crates/ui-egui/src/panels/edit.rs` (`hdr_row`) | HDR switch in the Light panel; see Q. HDR || LR-EDIT-LIGHT-EXPOSURE | Exposure | P0 | ✅ | `ctl:light.exposure` | || LR-EDIT-LIGHT-CONTRAST | Contrast | P0 | ✅ | `ctl:light.contrast` | |-| LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights` | |+| LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects or lens fringes beside it) and white where there is none (#523) || LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | || LR-EDIT-LIGHT-WHITES | Whites | P0 | ✅ | `ctl:light.whites` | || LR-EDIT-LIGHT-BLACKS | Blacks | P0 | ✅ | `ctl:light.blacks` | |