LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge PR #752
Claudea0e422ce4a03
diff --cc crates/engine/src/cmd/develop.rsindex 502800c08,88ec4bc25..42f59fe72--- a/crates/engine/src/cmd/develop.rs+++ b/crates/engine/src/cmd/develop.rs@@@ -178,12 -167,13 +178,15 @@@ pub fn specs() -> Vec<CommandSpec>}}let label = if vals.len() == 1 { controls::find(&vals[0].0).map(|c| c.label).unwrap_or("Edit").to_string() } else { "Edit".into() };- let apply = |d: &mut DevelopSettings, info: &lightcraft_pipeline::SourceInfo| {+ let angle = vals.iter().any(|(k, _)| k == CROP_ANGLE);+ let apply = |d: &mut DevelopSettings, info: &lightcraft_pipeline::SourceInfo, dims: (f64, f64)| {+ let before = d.crop.geometry;- if d.wb.mode == WbMode::AsShot && vals.iter().any(|(k, _)| k == "wb.temp" || k == "wb.tint") {- d.wb.temp = info.as_shot_temp;- d.wb.tint = info.as_shot_tint;+ if vals.iter().any(|(k, _)| k == "wb.temp" || k == "wb.tint") {+ lightcraft_pipeline::local::normalize_wb(d, info);+ if d.wb.mode == WbMode::AsShot {+ d.wb.temp = info.as_shot_temp;+ d.wb.tint = info.as_shot_tint;+ }}for (k, v) in &vals {controls::set(d, k, *v);@@@ -221,11 -209,10 +224,12 @@@let c = str_param(p, "control").ok_or_else(|| bad("develop.adjust", "missing control"))?.to_string();let spec = controls::find(&c).ok_or_else(|| bad("develop.adjust", "unknown control"))?;let delta = f64_req(p, "delta", "develop.adjust")?;- let info = s.source_info(active(s, "develop.adjust")?);+ let id = active(s, "develop.adjust")?;+ let (info, dims) = (s.source_info(id), crop_dims(s, id));edit(s, "develop.adjust", spec.label, |d| {+ let before = d.crop.geometry;if c == "wb.temp" || c == "wb.tint" {+ lightcraft_pipeline::local::normalize_wb(d, &info);if d.wb.mode == WbMode::AsShot {d.wb.temp = info.as_shot_temp;d.wb.tint = info.as_shot_tint;@@@ -257,15 -243,18 +261,22 @@@let fresh = match look {Some(l) => (*l).clone(),None => {+ // the photo's built-in defaults (raws: capture sharpening and colour noise+ // reduction, embedded lens corrections), as at import, with the white balance+ // of its current as-shot referencelet info = s.source_info(id);+ let defaults = s.catalog.photo(id).map(|p| p.camera_defaults()).unwrap_or_default();- DevelopSettings {- wb: lightcraft_develop::WhiteBalance { mode: WbMode::AsShot, temp: info.as_shot_temp, tint: info.as_shot_tint },+ let mut fresh = DevelopSettings {+ wb: lightcraft_develop::WhiteBalance {+ mode: WbMode::AsShot,+ temp: info.as_shot_temp,+ tint: info.as_shot_tint,+ ..Default::default()+ },- ..Default::default()+ ..defaults- }+ };+ lightcraft_pipeline::local::normalize_wb(&mut fresh, &info);+ fresh}};// a fresh start renders with the current process (a section or slider reset doesn't change it)@@@ -873,15 -860,17 +886,19 @@@.filter_map(|id| s.develop_of(id).map(|d| (id, d))).filter_map(|(id, d)| {let mut nd = (*d).clone();- if nd.wb.mode == WbMode::AsShot && (ctl == "wb.temp" || ctl == "wb.tint") {+ if ctl == "wb.temp" || ctl == "wb.tint" {+ // each photo on its own scale: Kelvin (an old relative value converted first) or relativelet info = s.source_info(id);- nd.wb.temp = info.as_shot_temp;- nd.wb.tint = info.as_shot_tint;+ lightcraft_pipeline::local::normalize_wb(&mut nd, &info);+ if nd.wb.mode == WbMode::AsShot {+ nd.wb.temp = info.as_shot_temp;+ nd.wb.tint = info.as_shot_tint;+ }}+ let before = nd.crop.geometry;let v = controls::get(&nd, &ctl).unwrap_or(spec.default);controls::set(&mut nd, &ctl, v + delta);+ refit_crop_angle(ctl == CROP_ANGLE, before, &mut nd, crop_dims(s, id));if ctl == "wb.temp" || ctl == "wb.tint" {nd.wb.mode = WbMode::Custom;}diff --cc crates/engine/src/cmd/previews.rsindex b46c13528,6094422f9..4fc7ababa--- a/crates/engine/src/cmd/previews.rs+++ b/crates/engine/src/cmd/previews.rs@@@ -331,9 -270,9 +331,9 @@@ fn smart(s: &mut Session, p: &Value) -if !matches!(ph.source, lightcraft_catalog::Source::File { .. }) {continue;}- let path = dir.join(crate::smart::file_name(&ph));+ let path = crate::smart::sharded_file_path(&dir, &ph);let source = (!discard).then(|| s.media.source_ref(&ph, crate::media::SourceLevel::Preview));- jobs.push((id, path, source, ph.relative_wb()));+ jobs.push((id, path, source, ph.fitted_look()));}let custom = s.smart_previews_dir.is_some();if background {@@@ -375,9 -314,9 +375,9 @@@ pub(crate) fn refresh_stale_smart_previreturn None;}let max_edge = crate::media::SourceLevel::Preview.max_edge();- let photos: Vec<_> = s.catalog.photos().filter(|p| matches!(p.source, lightcraft_catalog::Source::File { .. }) && p.relative_wb()).collect();+ let photos: Vec<_> = s.catalog.photos().filter(|p| matches!(p.source, lightcraft_catalog::Source::File { .. }) && p.fitted_look()).collect();let jobs: Vec<SmartJob> =- photos.iter().map(|p| (p.id, dir.join(crate::smart::file_name(p)), Some(s.media.origin_ref(&p.source, max_edge)), true)).collect();+ photos.iter().map(|p| (p.id, crate::smart::sharded_file_path(&dir, p), Some(s.media.origin_ref(&p.source, max_edge)), true)).collect();std::thread::Builder::new().name("lc-smart-look".into()).spawn(move || refresh_stale(&dir, jobs))diff --cc crates/engine/src/files.rsindex c7a429a3d,604cc96b9..be1a348ce--- a/crates/engine/src/files.rs+++ b/crates/engine/src/files.rs@@@ -165,11 -131,9 +165,9 @@@ pub fn probe_bytes(name: &str, bytes: &if raw.orientation.swaps_axes() {std::mem::swap(&mut w, &mut h);}- let (t, tint) = xy_to_temp_tint(lightcraft_raw::color::as_shot_white_xy_of(&raw));- // Vendor RGB multipliers do not identify an absolute illuminant without camera calibration.- let relative = crate::camera_preview::file_local_look(raw.format) && !lightcraft_raw::color::has_matrix(&raw.color);- let as_shot_wb = Some(if relative { (6500.0, 0.0) } else { (t.round(), tint.round()) });+ let scale = WbScaleOf::new(raw.format, &raw.color, raw.wb_multipliers, &raw.metadata);+ let as_shot_wb = Some(scale.as_shot(lightcraft_raw::color::as_shot_white_xy_of(&raw)));- let embedded_lens = embedded_lens(&raw);+ let embedded_lens = crate::lens_profiles::for_raw(&raw, || m.clone());return Ok(ProbeInfo {embedded_lens,width: w,@@@ -399,10 -363,11 +397,11 @@@ fn load_bytes_now// Embedded lens corrections are applied by the pipeline ("Enable Profile Corrections"), not baked in// (removed before the camera look's binned sensor proxy too, which needs an empty `OpcodeList3`).let info = raw.info();- let lens = embedded_lens(&info);+ let lens = crate::lens_profiles::for_raw(&info, || lightcraft_meta::extract(&bytes));raw.opcodes.list3.retain(|op| !op.is_lens_correction());- // Without colour matrices of its own, white balance is relative to the as-shot look (`Photo::relative_wb`).- let own_matrix = lightcraft_raw::color::has_matrix(&raw.color);+ // Which scale white balance is edited on, and the as-shot white on it, from the file's own colour tags or+ // 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 fittedlet ((xy, t, camera_look), mattes) = rayon::join(|| crate::camera_preview::starting_colour(&mut raw, &bytes), || dng_mattes(&bytes, &info));drop(bytes);diff --cc docs/camera-preview-colour.mdindex 57150bfcc,a6a6074bf..b24d9bf75--- a/docs/camera-preview-colour.md+++ b/docs/camera-preview-colour.md@@@ -121,13 -123,12 +125,14 @@@ A raw starts from the first of these th4. the model's spectral matrices, with LightCraft's default tone curve and no JPEG fit;5. the neutral fallback.+When the file's JPEG is black and white, step 2 fits the tone curve alone with the profile's colour; without a profile, or when that fit fails, 4 and 5 take the tone curve fitted to it (see the black-and-white JPEG paragraph above).+The spectral matrices only replace the neutral fallback: a photo whose JPEG fit is accepted (with or without aprofile) renders exactly as before, and a covered model takes its spectral matrices only when that fit fails the- gates or the file has no usable JPEG. White balance stays relative to the as-shot look for every raw without matrices- of its own, as before, so the catalog's `Photo::relative_wb` and the controls are unchanged. `lightcraft-cli- calibrate` still pools the uncorrected camera colour of covered models, so a profile can be fitted for them.+ gates or the file has no usable JPEG. White balance of a covered model is in Kelvin through its matrices whichever+ look it got (above, issue #730); for every other raw without matrices of its own it stays relative to the as-shot+ look (`Photo::relative_wb`). `lightcraft-cli calibrate` still pools the uncorrected camera colour of covered+ models, so a profile can be fitted for them.No colour-difference measurement of the spectral matrices against the camera JPEG, or against the file-local fit,is recorded here yet. Whether they should come before the file-local fit for these models is open until one is.diff --cc docs/mcp.mdindex 0fb659140,b12dc11bf..1b3b4c038--- a/docs/mcp.md+++ b/docs/mcp.md@@@ -164,9 -164,9 +164,9 @@@ per-request `_meta` receive `resultType| `select_photos {ids, active?, mode?}` | Set the selection / active photo. Every id (and `active`) must be in the library: an unknown id is a tool error (`no such photo 9999`) and the selection and active photo are left as they were || `list_controls {section?}` | Every develop slider: id (`light.exposure`…), range, default, current value || `get_develop {id?}` | Full develop-settings JSON, with `process`: the rendering process the photo is on ([process-versions.md](process-versions.md)) |- | `set_develop {id?, values?, settings?, label?}` | `values`: `{controlId: number}`; `settings`: partial develop JSON deep-merged. Undoable. A `crop.angle` value turns the crop as `crop.straighten` does: kept if it still fits, else shrunk to the largest crop of its aspect inside the photo (`settings` is merged as given, unfitted) |-| `set_develop {id?, values?, settings?, label?}` | `values`: `{controlId: number}`; `settings`: partial develop JSON deep-merged. Undoable. White balance: `values` with `wb.temp` / `wb.tint` is Kelvin on raws with colour matrices (DNG, and cameras LightCraft has matrices for) and relative (6500 = as shot) elsewhere; a `settings.wb` with `temp` / `tint` and no `"scale": "kelvin"` is read on the relative scale on every raw (see [control-protocol.md](control-protocol.md)) |++| `set_develop {id?, values?, settings?, label?}` | `values`: `{controlId: number}`; `settings`: partial develop JSON deep-merged. Undoable. A `crop.angle` value turns the crop as `crop.straighten` does: kept if it still fits, else shrunk to the largest crop of its aspect inside the photo (`settings` is merged as given, unfitted). White balance: `values` with `wb.temp` / `wb.tint` is Kelvin on raws with colour matrices (DNG, and cameras LightCraft has matrices for) and relative (6500 = as shot) elsewhere; a `settings.wb` with `temp` / `tint` and no `"scale": "kelvin"` is read on the relative scale on every raw (see [control-protocol.md](control-protocol.md)) || `apply_preset {preset, amount?, ids?}` | Apply a preset (ids from `cmd_presets_list`) |-| `crop {id?, rect?, angle?, reset?}` | Normalized crop rect `[x0,y0,x1,y1]` and straighten angle; at least one of `rect`, `angle`, `reset: true` |+| `crop {id?, rect?, angle?, reset?}` | Normalized crop rect `[x0,y0,x1,y1]` and straighten angle; at least one of `rect`, `angle`, `reset: true`. The crop always ends inside the photo: an `angle` alone keeps the crop if it still fits, else shrinks it to the largest of its aspect that does || `render_photo {id?, size?, format?, path?}` | Render with current settings → **image content** (PNG, or JPEG with `format: "jpeg"`), long edge `size` (default 1024) || `export {path \| dir, id? \| ids?, format?, longEdge? \| shortEdge? \| width?/height? \| megapixels? \| percent?, dontEnlarge?, ppi?, quality?, colorSpace?, bitDepth?, …}` | Full-quality render to `.png` / `.jpg` / `.tif` / `.webp` / `.avif`; `format: "original"` copies the file + an XMP sidecar with the edits, `format: "dng"` writes raw photos as DNG with the edits embedded. No size param = 3000 px long edge; `longEdge: 0` = full size (cropped, native resolution); `width` + `height` fit either orientation; `dontEnlarge` defaults to true |diff --cc docs/parity-checklist.mdindex 00f4b4d21,dae1650d5..febb9723a--- a/docs/parity-checklist.md+++ b/docs/parity-checklist.md@@@ -188,8 -188,8 +188,8 @@@ differences and missing bindings are i| LR-EDIT-LIGHT-CURVE-REFINESAT | Curve saturation compensation | P1 | ✅ | `ctl:curve.refineSaturation` | || LR-EDIT-LIGHT-CURVE-TAT | Drag-on-image curve adjust | P1 | ✅ | `cmd:develop.targeted` (`target: curve`) | || LR-EDIT-COLOR-WB-PRESET | White-balance presets | P0 | ✅ | `cmd:develop.wb` | |-| LR-EDIT-COLOR-WB-PICKER | White-balance eyedropper | P0 | ✅ | `cmd:tool.wbPicker`, `cmd:develop.wbPick` | no magnified loupe while picking |+| LR-EDIT-COLOR-WB-PICKER | White-balance eyedropper | P0 | ✅ | `cmd:tool.wbPicker`, `cmd:develop.wbPick`, `crates/ui-egui/src/tests_wb_selector.rs` | the Edit panel's selector button does what W does (from Compare, Survey or the grid it opens the photo in Detail); no magnified loupe while picking |- | LR-EDIT-COLOR-TEMP | Temperature | P0 | ✅ | `ctl:wb.temp`, `crates/pipeline/src/local.rs` (`wb_matrix_for`), `crates/raw/src/color.rs` (`rebalance`) | relative scale for non-raw in the UI; raws with a colour matrix (DNG and other raws without a file-local look) are re-developed for the chosen white through the camera's own matrices (camera-space white balance, as Lightroom), and the eyedropper / Auto invert the same model; other photos are adapted (Bradford) |+ | LR-EDIT-COLOR-TEMP | Temperature | P0 | ✅ | `ctl:wb.temp`, `crates/pipeline/src/local.rs` (`wb_matrix_for`, `legacy_white`), `crates/raw/src/color.rs` (`rebalance`), `crates/raw/src/spectral.rs` (`find_camera`), `crates/catalog/src/model.rs` (`relative_wb_camera`) | Kelvin (2000–50000 K, As Shot read from the file) on raws with colour matrices: in the file (DNG: re-developed for the chosen white through the camera's own matrices, camera-space white balance as Lightroom; the eyedropper / Auto invert the same model) or measured for the camera model (`lightcraft_raw::spectral`, 52 bodies, issue #730: the matrices turn the as-shot multipliers into Kelvin and the slider back, the look stays the file's fit, and the picture is adapted from the as-shot white, Bradford); raws without matrices anywhere and rendered files use the relative −100..+100 scale (6500 K / 0 = as shot). Settings written on the relative scale before a camera's matrices reached it keep their look (`WbScale`). Not verified against Lightroom's Kelvin: on the ILCE-7M3 the matrices read 7–10 % below Sony's dial (issue #730), and whether the matrices or the dial are off is open || LR-EDIT-COLOR-TINT | Tint | P0 | ✅ | `ctl:wb.tint`, `docs/tint-direction.md` | DNG / Lightroom sign: negative (left) adds green, positive (right) magenta; XMP `crs:Tint` values render as in Lightroom (issue #188); CPU/GPU regression tests || LR-EDIT-COLOR-VIBRANCE | Vibrance | P0 | ✅ | `ctl:color.vibrance` | || LR-EDIT-COLOR-SATURATION | Saturation | P0 | ✅ | `ctl:color.saturation` | |diff --cc docs/whats-new.mdindex 9c5821653,9a1e00929..034da5c05--- a/docs/whats-new.md+++ b/docs/whats-new.md@@@ -1,46 -1,20 +1,59 @@@# What's new in LightCraft+## 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.+### Activity stack- Long-running tasks show in one place, top left under the top bar, as in Lightroom Classic (issue #345): imports andfolder scans, exports (and the contact sheet PDF), Synchronize Folder, Build / Smart Previews, Lightroom catalog import, Photo Merge, model downloads, the face scan,diff --cc docs/xmp-interop.mdindex aa5cc344f,3c7047f99..28a88a8d4--- a/docs/xmp-interop.md+++ b/docs/xmp-interop.md@@@ -108,9 -108,8 +108,9 @@@ application's renderer and is ignored:|---|---|---|| `Exposure2012` | `light.exposure` | EV, 1:1 || `Contrast2012`, `Highlights2012`, `Shadows2012`, `Whites2012`, `Blacks2012` | `light.contrast` … `light.blacks` | −100..100, 1:1 |+| `HDREditMode` | `hdr.enabled` | `1` / `True` = HDR editing on, `0` / `False` off || `WhiteBalance` | `wb.mode` | `As Shot`, `Auto`, `Daylight`, `Cloudy`, `Shade`, `Tungsten`, `Fluorescent`, `Flash`; other names → custom |- | `Temperature`, `Tint` | `wb.temp`, `wb.tint` | Kelvin / tint as written for raws with a measured illuminant (DNG) and for presets. Raws LightCraft develops relative to their as-shot look (ARW, NEF, RW2, RAF, CR3, CR2, PEF, SRW: 6500 K / 0 means as shot) take the same mired shift from the packet's `AsShotTemperature` / `AsShotTint` instead; without that reference a custom Kelvin stays As Shot and is reported (`Temperature, Tint (custom white balance without AsShotTemperature: kept As Shot)`), because read on the relative scale it would be a large colour cast (issue #510) |+ | `Temperature`, `Tint` | `wb.temp`, `wb.tint` (+ `wb.scale: kelvin`) | Kelvin / tint as written for raws with colour matrices — in the file (DNG) or measured for the camera (`lightcraft_raw::spectral`: ILCE-7M3, D850, EOS 5D Mark III…, issue #730) — and for presets; the mapped settings say `"scale": "kelvin"` so the value stays Kelvin wherever it lands. Raws LightCraft develops relative to their as-shot look (ARW, NEF, RW2, RAF, CR3, CR2, PEF, SRW of other cameras: 6500 K / 0 means as shot) take the same mired shift from the packet's `AsShotTemperature` / `AsShotTint` instead; without that reference a custom Kelvin stays As Shot and is reported (`Temperature, Tint (custom white balance without AsShotTemperature: kept As Shot)`), because read on the relative scale it would be a large colour cast (issue #510). Note that LightCraft's Kelvin for a camera comes from its measured matrices, Lightroom's from Adobe's: the two scales differ (about 7–10 % on the ILCE-7M3), so the number is carried over, not the exact look || `IncrementalTemperature`, `IncrementalTint` | `wb.temp`, `wb.tint` | rendered files: −100..100 on our relative scale (mired shift around 6500 K, same as the Temp slider); a rendered file with only `Temperature` shifts from `AsShotTemperature` like the raws above when it is present || `Vibrance`, `Saturation` | `color.vibrance`, `color.saturation` | 1:1 || `Texture`, `Clarity2012`, `Dehaze` | `effects.texture`, `effects.clarity`, `effects.dehaze` | 1:1 |