From 2f7f61b8a9b9b1b4367b576a5fb762557cf1e77c Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 14 Oct 2026 10:24:19 +0200 Subject: [PATCH 1/8] LR-META-EXIF-FULL: preserve shutter precision through import and export (#1619) Share lossless duration formatting between catalog import and All Metadata. Keep the catalog schema unchanged and cover persisted metadata round trips. Co-authored-by: Codex --- crates/engine/src/files.rs | 23 ++++++++++++++++++++++- crates/meta/src/lib.rs | 31 +++++++++++++++++++++++++------ crates/meta/src/tags.rs | 24 +++++++++++++++++++++++- docs/parity-checklist.md | 5 +++-- 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/files.rs b/crates/engine/src/files.rs index e2144eb859..f26e0b2307 100644 --- a/crates/engine/src/files.rs +++ b/crates/engine/src/files.rs @@ -14,7 +14,7 @@ use lightcraft_raster::resample::{Filter, fit}; use crate::media::{DenoiseSpec, FileLoader, FileProbe, PairLoader, PreviewLoader, ProbeInfo}; fn meta_of(m: &lightcraft_meta::Metadata) -> (Meta, Option) { - let shutter = m.exposure_time.map(|t| if t >= 1.0 { format!("{t:.0}") } else { format!("1/{:.0}", 1.0 / t) }).unwrap_or_default(); + let shutter = m.exposure_display().map(|s| s.trim_end_matches('″').to_string()).unwrap_or_default(); let camera = [m.make.clone().unwrap_or_default(), m.model.clone().unwrap_or_default()].join(" ").trim().to_string(); let meta = Meta { camera, @@ -1049,6 +1049,27 @@ impl crate::Session { #[cfg(test)] mod tests { + #[test] + fn imported_shutter_times_survive_catalog_and_export_metadata() { + use lightcraft_catalog::{Catalog, Photo, PhotoId}; + for t in [0.3, 0.4, 0.6, 0.8, 1.3, 1.6, 2.5, 3.2, 0.625, 1.0 / 2.8, 0.003, 1.0 / 250.0] { + let original = lightcraft_meta::Metadata { exposure_time: Some(t), ..Default::default() }; + let (meta, _) = meta_of(&original); + assert_eq!(lightcraft_catalog::parse_shutter_seconds(&meta.shutter), Some(t)); + // Exercise the persisted string, not a value kept alongside it in memory. + let meta: Meta = serde_json::from_str(&serde_json::to_string(&meta).unwrap()).unwrap(); + let mut photo = Photo::new(PhotoId(1), lightcraft_catalog::Source::Demo { scene: 0 }, "capture.jpg", "JPEG", 2, 2, ""); + photo.meta = meta; + let exported = crate::export::export_metadata(&photo, &Catalog::new(), &crate::export::ExportOptions::default()).unwrap(); + assert_eq!(exported.exposure_time, Some(t)); + let bytes = + crate::export::encode_with_metadata(&lightcraft_raster::Rgba8::new(2, 2), &crate::export::ExportOptions::default(), Some(&exported)) + .unwrap(); + let back = lightcraft_meta::extract(&bytes); + assert!((back.exposure_time.unwrap() - t).abs() < 0.000001, "{t}: {:?}", back.exposure_time); + } + } + /// Keywords from a file keep their hierarchy: the paths of `lr:hierarchicalSubject`, not the /// flat names of `dc:subject` that LightCraft's exports (and Lightroom Classic) write besides /// them; an exported `travel|Italy|Rome` comes back as itself. diff --git a/crates/meta/src/lib.rs b/crates/meta/src/lib.rs index 31a35cc652..772c3900c8 100644 --- a/crates/meta/src/lib.rs +++ b/crates/meta/src/lib.rs @@ -222,18 +222,21 @@ impl Metadata { } } - /// Exposure time formatted like cameras show it: `1/250`, `0.5`, `2″`. + /// Exposure time without rounding away capture metadata: `1/250`, `0.625`, `1.3″`. pub fn exposure_display(&self) -> Option { let t = self.exposure_time?; - if t.is_nan() || t <= 0.0 { + if !t.is_finite() || t <= 0.0 { return None; } - Some(if t < 0.3 { - format!("1/{}", (1.0 / t).round()) + let denominator = (1.0 / t).round(); + // Only use a reciprocal when parsing it recovers the original duration. + // Decimal thirds of a stop and unusual camera rationals must not be quantized. + Some(if t < 0.3 && denominator.is_finite() && 1.0 / denominator == t { + format!("1/{denominator}") } else if t < 1.0 { - format!("{}", (t * 10.0).round() / 10.0) + t.to_string() } else { - format!("{}″", (t * 10.0).round() / 10.0) + format!("{t}″") }) } @@ -306,6 +309,22 @@ mod tests { assert_eq!(parse_number("inf"), None); } + #[test] + fn exposure_display_preserves_duration() { + for t in [0.3, 0.4, 0.6, 0.8, 1.3, 1.6, 2.5, 3.2, 0.625, 1.0 / 2.8, 0.003, 1.0 / 250.0] { + let text = Metadata { exposure_time: Some(t), ..Default::default() }.exposure_display().unwrap(); + let number = text.trim_end_matches('″'); + let actual = match number.split_once('/') { + Some((n, d)) => n.parse::().unwrap() / d.parse::().unwrap(), + None => number.parse::().unwrap(), + }; + assert_eq!(actual, t, "{text}"); + } + for t in [0.0, -1.0, f64::NAN, f64::INFINITY, f64::NEG_INFINITY] { + assert!(Metadata { exposure_time: Some(t), ..Default::default() }.exposure_display().is_none()); + } + } + #[test] fn exposure_display() { let mut m = Metadata { exposure_time: Some(1.0 / 250.0), ..Default::default() }; diff --git a/crates/meta/src/tags.rs b/crates/meta/src/tags.rs index 39e26097d6..d69b25735f 100644 --- a/crates/meta/src/tags.rs +++ b/crates/meta/src/tags.rs @@ -237,7 +237,11 @@ fn value_text(group: &str, tag: u16, v: &Value) -> String { // exposure time as a fraction of a second let (n, d) = a[0]; let s = n as f64 / d as f64; - if s >= 1.0 || n == 0 { format!("{} s", rational(n as f64, d as f64)) } else { format!("1/{} s", (1.0 / s).round()) } + let display = crate::Metadata { exposure_time: Some(s), ..Default::default() }.exposure_display(); + match display { + Some(text) => format!("{} s", text.trim_end_matches('″')), + None => format!("{} s", rational(n as f64, d as f64)), + } } Value::Rational(a) if tag == 0x829d && group != "GPS" && a.len() == 1 => format!("f/{}", rational(a[0].0 as f64, a[0].1 as f64)), Value::Rational(a) if tag == 0x920a && group != "GPS" && a.len() == 1 => format!("{} mm", rational(a[0].0 as f64, a[0].1 as f64)), @@ -355,6 +359,24 @@ pub fn file_tag_rows(bytes: &[u8]) -> Vec { #[cfg(test)] mod tests { + #[test] + fn exposure_rows_do_not_round_third_stop_times() { + for (n, d, expected) in [ + (3, 10, "0.3 s"), + (4, 10, "0.4 s"), + (6, 10, "0.6 s"), + (8, 10, "0.8 s"), + (13, 10, "1.3 s"), + (16, 10, "1.6 s"), + (25, 10, "2.5 s"), + (32, 10, "3.2 s"), + (5, 8, "0.625 s"), + (1, 250, "1/250 s"), + ] { + assert_eq!(value_text("EXIF", 0x829a, &Value::Rational(vec![(n, d)])), expected); + } + } + use super::*; #[test] diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 7bb187811c..f7a4b2b381 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -168,7 +168,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-META-LOCATION | Location editing | P2 | 🟡 | `cmd:photo.setMeta` (`location`, `city`, `state`, `country`, `gps`), `cmd:metadata.reverseGeocode` | place fields and GPS (decimal or degrees / minutes / seconds) edited in Info, read/written as IPTC Core / Photoshop / EXIF XMP; Show on Map opens OpenStreetMap; Fill Location fills empty City / State / Country from GPS offline (GeoNames, downloaded on request: `cmd:metadata.downloadPlaceNames`); no embedded map | | LR-META-COPYPASTE | Copy / paste metadata | P2 | ✅ | `cmd:photo.copyMetadata`, `cmd:photo.pasteMetadata` | title, caption, alt text, extended description, copyright (notice, status, usage terms, info URL), creator, place fields, keywords; `fields` picks a subset | | LR-META-XMP | XMP read/write | P0 | ✅ | `cmd:photo.saveMetadataToFile`, `cmd:photo.readMetadataFromFile`, `cmd:library.xmpPreferences`, `crates/engine/src/sidecar.rs`, `docs/xmp-interop.md` | sidecar wins for metadata; a sidecar capture time (`exif:DateTimeOriginal` / `photoshop:DateCreated` / `xmp:CreateDate`) fills in only when the file has none; saving merges into an existing sidecar (`crates/meta/src/xmp_merge.rs`): another app's `crs:`, `xmpMM:History` and unknown namespaces are kept byte for byte, an unreadable sidecar is backed up first; with stem naming, files sharing a stem (raw + JPEG) get separate sidecars (`.xmp` for all but the raw); a `crs:` custom white balance on a relative-WB raw is shifted from `crs:AsShotTemperature` rather than read as Kelvin, or kept As Shot and reported when the packet has no as-shot white (issue #510); heal and clone spots (`crs:RetouchAreas`, legacy `crs:RetouchInfo`) are read into our spots (`crates/engine/src/crs_masks.rs`, see `docs/xmp-interop.md` → Spot removal); Read Metadata from File never writes the sidecar back, even with auto-write on, so another app's later `crs:` edits are still read (issue #934) | -| LR-META-EXIF-FULL | Full EXIF/IPTC [Classic] | P1 | ✅ | `cmd:photo.allMetadata`, `cmd:dialog.allMetadata`, `crates/meta/src/tags.rs`, `crates/meta/src/exif.rs`, `crates/meta/src/iptc.rs` | read and written on export; Info ▸ All Metadata…: every TIFF / EXIF / GPS / interop tag (named, common values spelled out) and the XMP fields, searchable; metadata presets | +| LR-META-EXIF-FULL | Full EXIF/IPTC [Classic] | P1 | ✅ | `cmd:photo.allMetadata`, `cmd:dialog.allMetadata`, `crates/meta/src/tags.rs`, `crates/meta/src/exif.rs`, `crates/meta/src/iptc.rs` | read and written on export; Info ▸ All Metadata…: every TIFF / EXIF / GPS / interop tag (named, common values spelled out) and the XMP fields, searchable; metadata presets Exposure durations retain their precision in imported catalog metadata and All Metadata (#1619). | ## F. Edit panel — global adjustments (EDIT) @@ -393,7 +393,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EXP-COLORSPACE | Output colour space | P0 | ✅ | `cmd:app.export` (`colorSpace`), `crates/pipeline/src/output.rs`, `crates/engine/src/export.rs` | sRGB, Display P3, Adobe RGB (1998) compatible, ProPhoto RGB, Rec. 2020: rendered from the working space with gamut mapping into the target gamut (CPU + GPU), own ICC profile embedded; AVIF stays sRGB (muxer has no ICC); lossy JPEG XL declares sRGB / P3 / Rec. 2020 (Adobe RGB and ProPhoto written as Rec. 2020), lossless JPEG XL embeds the profile | | LR-EXP-HDR | HDR output | P2 | 🟡 | `cmd:app.export`, `crates/ui-egui/src/panels/dialogs.rs` | HDR output checkbox in the export dialog: gain map JPEG, PQ or HLG AVIF, PQ PNG, PQ JPEG XL, float TIFF; no HDR presets yet | | LR-EXP-SHARPEN | Output sharpening | P1 | ✅ | `cmd:app.export` (`sharpen`, `sharpenAmount`) | | -| LR-EXP-METADATA | Metadata policy | P1 | ✅ | `cmd:app.export` (`metadata`, `removeLocation`) | | +| LR-EXP-METADATA | Metadata policy | P1 | ✅ | `cmd:app.export` (`metadata`, `removeLocation`) | Exposure durations survive catalog serialization and export without import-time reciprocal or whole-second rounding (#1619); previously rounded catalog values require reloading metadata from the original. | | LR-EXP-WATERMARK | Watermark | P1 | ✅ | `cmd:app.export` (`watermark`: text, or `{text, vertical, size, opacity, anchor, insetX, insetY, inset, rotation, color, shadow, image, imageWidth}`), `crates/engine/src/export.rs` (`Watermark`, `WATERMARK_PARAMS`) | text (`size` = height as a fraction of the short edge, 0.005..0.5, default 0.035; `color` sRGB `[r,g,b]`; `shadow`; Japanese vertical glyph forms and origins, tested by `biz_ud_vertical_watermarks_place_punctuation_at_the_top_right`; extended grapheme cells keep decomposed dakuten/handakuten and Latin accents together, tested by `vertical_watermarks_keep_combining_marks_in_one_cell` and `upright_watermark_cell_retains_multiple_glyphs` (see `docs/vertical-watermarks.md`)) or a graphic with transparency (`image` path, `imageWidth` = fraction of the photo's width, 0.01..1, converted to the output colour space); `anchor` (nine positions), `insetX` / `insetY` (margins from the side and from the top/bottom edges, each a fraction of the short edge, 0..0.4; the Export dialog's Horizontal and Vertical inset sliders, as in Lightroom Classic; the older single `inset` still reads as both; tested by `watermark_insets_are_horizontal_and_vertical`), `rotation` (0, 90, 180 or 270 degrees clockwise, the Export dialog's Rotate row, as Lightroom Classic's rotate buttons; sized before it is turned, placed and inset by the turned box; tested by `watermark_rotation_turns_the_text_in_its_corner` and `graphic_watermark_is_placed_scaled_and_blended`), `opacity` 0..1. Unknown keys and out-of-range values are errors (issue #183). The Export dialog previews it on the first exported photo's thumbnail (`draw_watermark_preview` scales the 6 px minimum text size to the preview so it matches the file), tested by `watermark_preview_scales_the_minimum_text_size` and `export_dialog_previews_the_watermark` | | LR-EXP-NAMING | File naming | P1 | ✅ | `cmd:app.export` (`naming`, `startNumber`), `crates/engine/src/rename.rs` (`expand_tokens`) | one template language for export, Rename Photos and import renaming: `{name}`, `{num}` (number at the end of the name), `{seq}` / `{seq:N}`, `{date}` / `{date:%Y-%m-%d}`, `{folder}`, `{camera}`, `{lens}`, `{iso}`, `{rating}`, `{title}`, `{creator}`, `{ext}`; free-form template rather than a list of named schemes | | LR-EXP-LOCATION | Destination folder | P0 | ✅ | `cmd:app.export` (`dir`, `subfolder`, `conflict`: unique / overwrite / skip), `cmd:export.checkTarget`, `crates/ui-egui/src/panels/dialogs.rs` (Choose… folder picker), `crates/engine/src/originals.rs`, `crates/catalog/src/safe_file.rs` | folder picker on the desktop; existing files get `-2`, `-3`… by default; the policy covers a file and its sidecars together; a catalogued original (or its sidecar) is never written over, whatever the policy or an exact `path` (export, `ui.render`, MCP `render_photo`, merge `previewPath`, `lightcraft-cli render`); files are written to a temp file and renamed into place (issue #93; not synced file by file — exports can be made again, issue #134) | @@ -790,6 +790,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | Date | Change | Summary | |---|---|---| +| 2026-10-14 | patch | LR-META-EXIF-FULL, LR-EXP-METADATA: preserve shutter duration through import, display and export (#1619); no catalog schema change. Statuses and feature counts unchanged. | | 2026-10-13 | patch | LR-VIEW-COMPARE, LRC-LIB-COMPARE: ⌘/Ctrl- and Shift-clicks on the filmstrip in Compare change the selection as in the grid; the two photos shown stay selected and the active photo is unchanged (#187); statuses unchanged | | 2026-10-13 | minor | KEYC-SELECTONLYACTIVE: Edit → Select Only Active Photo (⌘⇧D) lands as a new row; status 🟡 (headless-tested, native macOS menu path unverified) | | 2026-10-13 | patch | LRC-LIB-CATALOG-IMPORT: a catalog whose tables are all still in its `-wal` file (main file schema format 0) opens instead of failing as an unsupported schema format; status unchanged | From 887752ff94410469da95e9b803b5f15416e0e0d9 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:51:55 +0200 Subject: [PATCH 2/8] LR-1619: one shutter formatter for display, exact time kept for export Show near-exact 1/n second as `1/n` and round everything else to four significant digits through lightcraft_meta::format_exposure_time, used by the catalog `shutter` text, the Info panel (which shows it) and All Metadata. The catalog keeps the exact duration in an optional `exposure_time` beside it (older catalogs read unchanged), and export, auto-stacking, smart-collection shutter rules and Match Total Exposures read it through Meta::shutter_seconds while the text still matches it. --- crates/catalog/src/model.rs | 42 +++++++++++++++ crates/catalog/src/rules.rs | 2 +- crates/catalog/src/stacks.rs | 2 +- crates/engine/src/cmd/convert.rs | 1 + crates/engine/src/cmd/develop.rs | 5 +- crates/engine/src/export.rs | 2 +- crates/engine/src/files.rs | 27 ++++++++-- crates/meta/src/lib.rs | 91 +++++++++++++++++++++++--------- crates/meta/src/tags.rs | 9 ++-- docs/parity-checklist.md | 6 +-- 10 files changed, 145 insertions(+), 42 deletions(-) diff --git a/crates/catalog/src/model.rs b/crates/catalog/src/model.rs index 6ac3544ee7..2c6f5cab08 100644 --- a/crates/catalog/src/model.rs +++ b/crates/catalog/src/model.rs @@ -171,7 +171,13 @@ pub struct Meta { pub lens: String, pub focal_mm: Option, pub aperture: Option, + /// Shutter speed for display, from [`lightcraft_meta::format_exposure_time`] (`1/3`, `0.3571`, `2.5`). pub shutter: String, + /// The file's exact exposure time in seconds, kept beside the rounded `shutter` text so export + /// writes the original duration; read through [`Meta::shutter_seconds`]. Left out of the catalog + /// JSON when unknown, so older catalogs read unchanged. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub exposure_time: Option, pub iso: Option, /// Place (sublocation, e.g. a landmark). pub location: String, @@ -206,6 +212,16 @@ pub struct Meta { pub focus: Option, } +impl Meta { + /// Shutter speed in seconds: the exact [`Meta::exposure_time`] while `shutter` still shows it, + /// otherwise whatever `shutter` says (set by hand, or a catalog from before the exact time was kept). + pub fn shutter_seconds(&self) -> Option { + self.exposure_time + .filter(|t| lightcraft_meta::format_exposure_time(*t).is_some_and(|text| text == self.shutter.trim())) + .or_else(|| parse_shutter_seconds(&self.shutter)) + } +} + #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Version { pub name: String, @@ -678,3 +694,29 @@ mod edited_tests { } } } + +#[cfg(test)] +mod shutter_tests { + use super::*; + + #[test] + fn shutter_seconds_prefers_the_exact_time_while_the_text_still_shows_it() { + let mut m = Meta { shutter: "0.3571".into(), exposure_time: Some(1.0 / 2.8), ..Default::default() }; + assert_eq!(m.shutter_seconds(), Some(1.0 / 2.8)); + m.shutter = "1/3".into(); + m.exposure_time = Some(1.0 / 3.0); + assert_eq!(m.shutter_seconds(), Some(1.0 / 3.0)); + // the text no longer matches the stored time (edited elsewhere): the text wins + m.shutter = "1/250".into(); + assert_eq!(m.shutter_seconds(), Some(1.0 / 250.0)); + // an older catalog without the exact time + m.exposure_time = None; + m.shutter = "2.5".into(); + assert_eq!(m.shutter_seconds(), Some(2.5)); + // the exact time stays out of the JSON when unknown, and round-trips when known + assert!(!serde_json::to_string(&m).unwrap().contains("exposure_time")); + m.exposure_time = Some(2.5); + let back: Meta = serde_json::from_str(&serde_json::to_string(&m).unwrap()).unwrap(); + assert_eq!(back.exposure_time, Some(2.5)); + } +} diff --git a/crates/catalog/src/rules.rs b/crates/catalog/src/rules.rs index a87c9effc0..42112c65f4 100644 --- a/crates/catalog/src/rules.rs +++ b/crates/catalog/src/rules.rs @@ -887,7 +887,7 @@ impl Rule { "captureDate" => date_op(op, p.captured.as_deref(), value), "importDate" => date_op(op, Some(&p.imported), value), "editDate" => date_op(op, p.edited.as_deref(), value), - "shutterSpeed" => num_op(op, crate::parse_shutter_seconds(&m.shutter), &shutter_value(value)), + "shutterSpeed" => num_op(op, m.shutter_seconds(), &shutter_value(value)), "iso" => num_op(op, m.iso.map(|v| v as f64), value), "aperture" => num_op(op, m.aperture.map(|v| v as f64), value), "focalLength" => num_op(op, m.focal_mm.map(|v| v as f64), value), diff --git a/crates/catalog/src/stacks.rs b/crates/catalog/src/stacks.rs index eb7e89ef4e..a3e9282370 100644 --- a/crates/catalog/src/stacks.rs +++ b/crates/catalog/src/stacks.rs @@ -260,7 +260,7 @@ impl Catalog { .filter(|p| !p.deleted && !merged(p)) .filter_map(|p| { let t = iso_seconds(p.captured.as_deref()?)?; - let s = crate::model::parse_shutter_seconds(&p.meta.shutter)?; + let s = p.meta.shutter_seconds()?; let n = p.meta.aperture.filter(|n| n.is_finite() && *n > 0.0).unwrap_or(1.0) as f64; let iso = p.meta.iso.filter(|i| *i > 0).unwrap_or(100) as f64; Some((t, p.file_name.as_str(), p.id, s, (s * iso / (n * n)).log2())) diff --git a/crates/engine/src/cmd/convert.rs b/crates/engine/src/cmd/convert.rs index eae955cce4..12c4c4ab4c 100644 --- a/crates/engine/src/cmd/convert.rs +++ b/crates/engine/src/cmd/convert.rs @@ -235,6 +235,7 @@ fn fill_missing_meta(id: lightcraft_catalog::PhotoId, ph: &lightcraft_catalog::P } if m.shutter.is_empty() { m.shutter = src.shutter.clone(); + m.exposure_time = src.exposure_time; } m.focal_mm = m.focal_mm.or(src.focal_mm); m.aperture = m.aperture.or(src.aperture); diff --git a/crates/engine/src/cmd/develop.rs b/crates/engine/src/cmd/develop.rs index e3d59c5672..54adb7f3f7 100644 --- a/crates/engine/src/cmd/develop.rs +++ b/crates/engine/src/cmd/develop.rs @@ -934,10 +934,7 @@ pub fn specs() -> Vec { // log2 of the light the photo gathered (shutter s × ISO / f-number²) let gathered = |s: &Session, id: PhotoId| -> Option { let m = &s.catalog.photo(id)?.meta; - let t = match m.shutter.split_once('/') { - Some((a, b)) => a.trim().parse::().ok()? / b.trim().parse::().ok()?, - None => m.shutter.trim().trim_end_matches('s').trim().parse::().ok()?, - }; + let t = m.shutter_seconds()?; let (n, iso) = (m.aperture? as f64, m.iso? as f64); (t > 0.0 && n > 0.0 && iso > 0.0).then(|| (t * iso / (n * n)).log2()) }; diff --git a/crates/engine/src/export.rs b/crates/engine/src/export.rs index e9d1cbc585..4d5a07cc45 100644 --- a/crates/engine/src/export.rs +++ b/crates/engine/src/export.rs @@ -1532,7 +1532,7 @@ pub fn export_metadata(photo: &lightcraft_catalog::Photo, catalog: &lightcraft_c out.lens_model = text(&m.lens); out.focal_length = m.focal_mm.map(f64::from); out.f_number = m.aperture.map(f64::from); - out.exposure_time = lightcraft_catalog::parse_shutter_seconds(&m.shutter); + out.exposure_time = m.shutter_seconds(); out.iso = m.iso; } Some(out) diff --git a/crates/engine/src/files.rs b/crates/engine/src/files.rs index 4111c02267..35a0c52ba3 100644 --- a/crates/engine/src/files.rs +++ b/crates/engine/src/files.rs @@ -14,7 +14,8 @@ use lightcraft_raster::resample::{Filter, fit}; use crate::media::{DenoiseSpec, FileLoader, FileProbe, PairLoader, PreviewLoader, ProbeInfo}; fn meta_of(m: &lightcraft_meta::Metadata) -> (Meta, Option) { - let shutter = m.exposure_display().map(|s| s.trim_end_matches('″').to_string()).unwrap_or_default(); + let exposure_time = m.exposure_time.filter(|t| t.is_finite() && *t > 0.0); + let shutter = exposure_time.and_then(lightcraft_meta::format_exposure_time).unwrap_or_default(); let camera = [m.make.clone().unwrap_or_default(), m.model.clone().unwrap_or_default()].join(" ").trim().to_string(); let meta = Meta { camera, @@ -23,6 +24,7 @@ fn meta_of(m: &lightcraft_meta::Metadata) -> (Meta, Option) { focal_mm: m.focal_length.map(|f| f as f32), aperture: m.f_number.map(|f| f as f32), shutter, + exposure_time, iso: m.iso, location: m.sublocation.clone().unwrap_or_default(), city: m.city.clone().unwrap_or_default(), @@ -1112,11 +1114,28 @@ pub(crate) mod tests { #[test] fn imported_shutter_times_survive_catalog_and_export_metadata() { use lightcraft_catalog::{Catalog, Photo, PhotoId}; - for t in [0.3, 0.4, 0.6, 0.8, 1.3, 1.6, 2.5, 3.2, 0.625, 1.0 / 2.8, 0.003, 1.0 / 250.0] { + for (t, shown) in [ + (0.3, "0.3"), + (0.4, "0.4"), + (0.6, "0.6"), + (0.8, "0.8"), + (1.3, "1.3"), + (1.6, "1.6"), + (2.5, "2.5"), + (3.2, "3.2"), + (30.0, "30"), + (0.625, "0.625"), + (1.0 / 2.8, "0.3571"), + (1.0 / 3.0, "1/3"), + (0.003, "0.003"), + (1.0 / 250.0, "1/250"), + (1.0 / 8000.0, "1/8000"), + ] { let original = lightcraft_meta::Metadata { exposure_time: Some(t), ..Default::default() }; let (meta, _) = meta_of(&original); - assert_eq!(lightcraft_catalog::parse_shutter_seconds(&meta.shutter), Some(t)); - // Exercise the persisted string, not a value kept alongside it in memory. + // the catalog shows a short shutter speed, never the raw f64 (`0.35714285714285715`) + assert_eq!(meta.shutter, shown, "{t}"); + // Exercise the persisted catalog JSON, not a value kept alongside it in memory. let meta: Meta = serde_json::from_str(&serde_json::to_string(&meta).unwrap()).unwrap(); let mut photo = Photo::new(PhotoId(1), lightcraft_catalog::Source::Demo { scene: 0 }, "capture.jpg", "JPEG", 2, 2, ""); photo.meta = meta; diff --git a/crates/meta/src/lib.rs b/crates/meta/src/lib.rs index 64307d9b06..1edfe9f312 100644 --- a/crates/meta/src/lib.rs +++ b/crates/meta/src/lib.rs @@ -157,6 +157,29 @@ macro_rules! overlay { ($self:ident, $o:ident, $($f:ident),*) => { $( if $o.$f.is_some() { $self.$f = $o.$f.clone(); } )* }; } +/// How far (relative) a duration may be from an exact `1/n` second and still be shown as `1/n`: +/// absorbs decimal EXIF rationals such as `3333/10000` for 1/3 s without turning 0.3 s or +/// 1/2.8 s into a reciprocal they aren't. +pub const RECIPROCAL_TOLERANCE: f64 = 1e-3; + +/// The one shutter-speed formatter for display (catalog `shutter`, Info panel, All Metadata): +/// a near-exact `1/n` second as `1/n` (`1/3`, `1/250`), anything else rounded to four +/// significant digits with trailing zeros dropped (`0.3`, `0.3571`, `2.5`, `30`). Display only: +/// export writes the exact duration. `None` for a time that isn't positive and finite. +pub fn format_exposure_time(t: f64) -> Option { + if !t.is_finite() || t <= 0.0 { + return None; + } + let n = (1.0 / t).round(); + if n >= 2.0 && n.is_finite() && (1.0 / (n * t) - 1.0).abs() <= RECIPROCAL_TOLERANCE { + return Some(format!("1/{n}")); + } + // four significant digits; whole seconds never lose digits + let decimals = (3 - t.log10().floor() as i32).max(0) as usize; + let text = format!("{t:.decimals$}"); + Some(if text.contains('.') { text.trim_end_matches('0').trim_end_matches('.').to_string() } else { text }) +} + impl Metadata { /// Fill every empty field of `self` from `other`. pub fn fill_missing(&mut self, other: &Metadata) { @@ -231,22 +254,10 @@ impl Metadata { } } - /// Exposure time without rounding away capture metadata: `1/250`, `0.625`, `1.3″`. + /// Exposure time formatted like cameras show it: `1/250`, `0.3571`, `2.5″` (see [`format_exposure_time`]). pub fn exposure_display(&self) -> Option { let t = self.exposure_time?; - if !t.is_finite() || t <= 0.0 { - return None; - } - let denominator = (1.0 / t).round(); - // Only use a reciprocal when parsing it recovers the original duration. - // Decimal thirds of a stop and unusual camera rationals must not be quantized. - Some(if t < 0.3 && denominator.is_finite() && 1.0 / denominator == t { - format!("1/{denominator}") - } else if t < 1.0 { - t.to_string() - } else { - format!("{t}″") - }) + format_exposure_time(t).map(|text| if t >= 1.0 { format!("{text}″") } else { text }) } /// Human name of the metering mode. @@ -342,18 +353,46 @@ mod tests { } #[test] - fn exposure_display_preserves_duration() { - for t in [0.3, 0.4, 0.6, 0.8, 1.3, 1.6, 2.5, 3.2, 0.625, 1.0 / 2.8, 0.003, 1.0 / 250.0] { - let text = Metadata { exposure_time: Some(t), ..Default::default() }.exposure_display().unwrap(); - let number = text.trim_end_matches('″'); - let actual = match number.split_once('/') { - Some((n, d)) => n.parse::().unwrap() / d.parse::().unwrap(), - None => number.parse::().unwrap(), - }; - assert_eq!(actual, t, "{text}"); + fn exposure_time_formats_reciprocals_and_significant_digits() { + for (t, want) in [ + (1.0 / 3.0, "1/3"), + (1.0 / 250.0, "1/250"), + (1.0 / 8000.0, "1/8000"), + (0.5, "1/2"), + (0.3, "0.3"), + (0.4, "0.4"), + (1.0 / 2.8, "0.3571"), + (0.625, "0.625"), + (0.003, "0.003"), + (1.0, "1"), + (1.3, "1.3"), + (2.5, "2.5"), + (30.0, "30"), + (9.99996, "10"), + (1800.0, "1800"), + ] { + assert_eq!(format_exposure_time(t).as_deref(), Some(want), "{t}"); } for t in [0.0, -1.0, f64::NAN, f64::INFINITY, f64::NEG_INFINITY] { - assert!(Metadata { exposure_time: Some(t), ..Default::default() }.exposure_display().is_none()); + assert_eq!(format_exposure_time(t), None, "{t}"); + } + } + + #[test] + fn exposure_time_reciprocal_tolerance() { + // a camera's decimal rational for 1/3 s, and times just inside the tolerance either side + assert_eq!(format_exposure_time(3333.0 / 10000.0).as_deref(), Some("1/3")); + // a microsecond-level rational error still reads as 1/8000; above ~1/1000 s every time is + // within the tolerance of some 1/n, which is how cameras show those speeds anyway + assert_eq!(format_exposure_time(1.0 / 8000.0 * (1.0 + 1e-5)).as_deref(), Some("1/8000")); + for n in [3.0, 10.0, 250.0] { + let inside = 0.9 * RECIPROCAL_TOLERANCE; + let outside = 1.1 * RECIPROCAL_TOLERANCE; + let want = format!("1/{n}"); + assert_eq!(format_exposure_time(1.0 / n * (1.0 + inside)).as_deref(), Some(want.as_str()), "{n} +inside"); + assert_eq!(format_exposure_time(1.0 / n * (1.0 - inside)).as_deref(), Some(want.as_str()), "{n} -inside"); + assert_ne!(format_exposure_time(1.0 / n * (1.0 + outside)).as_deref(), Some(want.as_str()), "{n} +outside"); + assert_ne!(format_exposure_time(1.0 / n * (1.0 - outside)).as_deref(), Some(want.as_str()), "{n} -outside"); } } @@ -362,7 +401,9 @@ mod tests { let mut m = Metadata { exposure_time: Some(1.0 / 250.0), ..Default::default() }; assert_eq!(m.exposure_display().as_deref(), Some("1/250")); m.exposure_time = Some(0.5); - assert_eq!(m.exposure_display().as_deref(), Some("0.5")); + assert_eq!(m.exposure_display().as_deref(), Some("1/2")); + m.exposure_time = Some(0.3); + assert_eq!(m.exposure_display().as_deref(), Some("0.3")); m.exposure_time = Some(2.0); assert_eq!(m.exposure_display().as_deref(), Some("2″")); m.exposure_time = Some(0.0); diff --git a/crates/meta/src/tags.rs b/crates/meta/src/tags.rs index 8fb339edf6..faedf04fe5 100644 --- a/crates/meta/src/tags.rs +++ b/crates/meta/src/tags.rs @@ -238,9 +238,8 @@ fn value_text(group: &str, tag: u16, v: &Value) -> String { // exposure time as a fraction of a second let (n, d) = a[0]; let s = n as f64 / d as f64; - let display = crate::Metadata { exposure_time: Some(s), ..Default::default() }.exposure_display(); - match display { - Some(text) => format!("{} s", text.trim_end_matches('″')), + match crate::format_exposure_time(s) { + Some(text) => format!("{text} s"), None => format!("{} s", rational(n as f64, d as f64)), } } @@ -384,7 +383,11 @@ mod tests { (25, 10, "2.5 s"), (32, 10, "3.2 s"), (5, 8, "0.625 s"), + (1, 3, "1/3 s"), + (10, 28, "0.3571 s"), (1, 250, "1/250 s"), + (1, 8000, "1/8000 s"), + (30, 1, "30 s"), ] { assert_eq!(value_text("EXIF", 0x829a, &Value::Rational(vec![(n, d)])), expected); } diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 10421430dc..4dfd3007b7 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -171,7 +171,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-META-LOCATION | Location editing | P2 | 🟡 | `cmd:photo.setMeta` (`location`, `city`, `state`, `country`, `gps`), `cmd:metadata.reverseGeocode` | place fields and GPS (decimal or degrees / minutes / seconds) edited in Info, read/written as IPTC Core / Photoshop / EXIF XMP; Show on Map opens OpenStreetMap; Fill Location fills empty City / State / Country from GPS offline (GeoNames, downloaded on request: `cmd:metadata.downloadPlaceNames`); no embedded map | | LR-META-COPYPASTE | Copy / paste metadata | P2 | ✅ | `cmd:photo.copyMetadata`, `cmd:photo.pasteMetadata` | title, caption, alt text, extended description, copyright (notice, status, usage terms, info URL), creator, place fields, keywords; `fields` picks a subset | | LR-META-XMP | XMP read/write | P0 | ✅ | `cmd:photo.saveMetadataToFile`, `cmd:photo.readMetadataFromFile`, `cmd:library.xmpPreferences`, `crates/engine/src/sidecar.rs`, `docs/xmp-interop.md` | sidecar wins for metadata; a sidecar capture time (`exif:DateTimeOriginal` / `photoshop:DateCreated` / `xmp:CreateDate`) fills in only when the file has none; saving merges into an existing sidecar (`crates/meta/src/xmp_merge.rs`): another app's `crs:`, `xmpMM:History` and unknown namespaces are kept byte for byte, an unreadable sidecar is backed up first; with stem naming, files sharing a stem (raw + JPEG) get separate sidecars (`.xmp` for all but the raw); a `crs:` custom white balance on a relative-WB raw is shifted from `crs:AsShotTemperature` rather than read as Kelvin, or kept As Shot and reported when the packet has no as-shot white (issue #510); heal and clone spots (`crs:RetouchAreas`, legacy `crs:RetouchInfo`) are read into our spots (`crates/engine/src/crs_masks.rs`, see `docs/xmp-interop.md` → Spot removal); radial masks (`Mask/CircularGradient`) keep Lightroom's inside / outside: `crs:Flipped="true"` is the effect-inside flag of current masks and of the legacy Radial Filter, `crs:MaskInverted` the inversion, checked against Lightroom Classic's renders (issue #1815); Read Metadata from File never writes the sidecar back, even with auto-write on, so another app's later `crs:` edits are still read (issue #934) | -| LR-META-EXIF-FULL | Full EXIF/IPTC [Classic] | P1 | ✅ | `cmd:photo.allMetadata`, `cmd:dialog.allMetadata`, `crates/meta/src/tags.rs`, `crates/meta/src/exif.rs`, `crates/meta/src/iptc.rs` | read and written on export; Info ▸ All Metadata…: every TIFF / EXIF / GPS / interop tag (named, common values spelled out) and the XMP fields, searchable; metadata presets. Exposure durations retain their precision in imported catalog metadata and All Metadata (#1619). | +| LR-META-EXIF-FULL | Full EXIF/IPTC [Classic] | P1 | ✅ | `cmd:photo.allMetadata`, `cmd:dialog.allMetadata`, `crates/meta/src/tags.rs`, `crates/meta/src/exif.rs`, `crates/meta/src/iptc.rs` | read and written on export; Info ▸ All Metadata…: every TIFF / EXIF / GPS / interop tag (named, common values spelled out) and the XMP fields, searchable; metadata presets. Shutter speeds in the catalog, Info and All Metadata use one formatter (`lightcraft_meta::format_exposure_time`): a near-exact 1/n s as `1/n`, otherwise four significant digits (#1619). | ## F. Edit panel — global adjustments (EDIT) @@ -398,7 +398,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EXP-COLORSPACE | Output colour space | P0 | ✅ | `cmd:app.export` (`colorSpace`), `crates/pipeline/src/output.rs`, `crates/engine/src/export.rs` | sRGB, Display P3, Adobe RGB (1998) compatible, ProPhoto RGB, Rec. 2020: rendered from the working space with gamut mapping into the target gamut (CPU + GPU), own ICC profile embedded; AVIF stays sRGB (muxer has no ICC); lossy JPEG XL declares sRGB / P3 / Rec. 2020 (Adobe RGB and ProPhoto written as Rec. 2020), lossless JPEG XL embeds the profile | | LR-EXP-HDR | HDR output | P2 | 🟡 | `cmd:app.export`, `crates/ui-egui/src/panels/dialogs.rs` | HDR output checkbox in the export dialog: gain map JPEG, PQ or HLG AVIF, PQ PNG, PQ JPEG XL, float TIFF; no HDR presets yet | | LR-EXP-SHARPEN | Output sharpening | P1 | ✅ | `cmd:app.export` (`sharpen`, `sharpenAmount`) | | -| LR-EXP-METADATA | Metadata policy | P1 | ✅ | `cmd:app.export` (`metadata`, `removeLocation`) | Exposure durations survive catalog serialization and export without import-time reciprocal or whole-second rounding (#1619); previously rounded catalog values require reloading metadata from the original. | +| LR-EXP-METADATA | Metadata policy | P1 | ✅ | `cmd:app.export` (`metadata`, `removeLocation`) | Export writes the exact exposure time kept in the catalog beside the rounded shutter text (#1619); previously rounded catalog values require reloading metadata from the original. | | LR-EXP-WATERMARK | Watermark | P1 | ✅ | `cmd:app.export` (`watermark`: text, or `{text, vertical, size, opacity, anchor, insetX, insetY, inset, rotation, color, shadow, image, imageWidth}`), `crates/engine/src/export.rs` (`Watermark`, `WATERMARK_PARAMS`) | text (`size` = height as a fraction of the short edge, 0.005..0.5, default 0.035; `color` sRGB `[r,g,b]`; `shadow`; Japanese vertical glyph forms and origins, tested by `biz_ud_vertical_watermarks_place_punctuation_at_the_top_right`; extended grapheme cells keep decomposed dakuten/handakuten and Latin accents together, tested by `vertical_watermarks_keep_combining_marks_in_one_cell` and `upright_watermark_cell_retains_multiple_glyphs` (see `docs/vertical-watermarks.md`)) or a graphic with transparency (`image` path, `imageWidth` = fraction of the photo's width, 0.01..1, converted to the output colour space); `anchor` (nine positions), `insetX` / `insetY` (margins from the side and from the top/bottom edges, each a fraction of the short edge, 0..0.4; the Export dialog's Horizontal and Vertical inset sliders, as in Lightroom Classic; the older single `inset` still reads as both; tested by `watermark_insets_are_horizontal_and_vertical`), `rotation` (0, 90, 180 or 270 degrees clockwise, the Export dialog's Rotate row, as Lightroom Classic's rotate buttons; sized before it is turned, placed and inset by the turned box; tested by `watermark_rotation_turns_the_text_in_its_corner` and `graphic_watermark_is_placed_scaled_and_blended`), `opacity` 0..1. Unknown keys and out-of-range values are errors (issue #183). The Export dialog previews it on the first exported photo's thumbnail (`draw_watermark_preview` scales the 6 px minimum text size to the preview so it matches the file), tested by `watermark_preview_scales_the_minimum_text_size` and `export_dialog_previews_the_watermark` | | LR-EXP-NAMING | File naming | P1 | ✅ | `cmd:app.export` (`naming`, `startNumber`), `crates/engine/src/rename.rs` (`expand_tokens`) | one template language for export, Rename Photos and import renaming: `{name}`, `{num}` (number at the end of the name), `{seq}` / `{seq:N}`, `{date}` / `{date:%Y-%m-%d}`, `{folder}`, `{camera}`, `{lens}`, `{iso}`, `{rating}`, `{title}`, `{creator}`, `{ext}`; free-form template rather than a list of named schemes | | LR-EXP-LOCATION | Destination folder | P0 | ✅ | `cmd:app.export` (`dir`, `destinationMode`: specificFolder / sameAsOriginal, `subfolder`, `conflict`: unique / overwrite / skip), `cmd:export.checkTarget`, `crates/ui-egui/src/panels/dialogs.rs` (Choose… folder picker), `crates/engine/src/originals.rs`, `crates/catalog/src/safe_file.rs` | folder picker on the desktop; Export to: Specific folder or Same folder as original photo (each photo into its original's folder + the subfolder; a demo/browser photo or a missing folder is that photo's error, issue #956); existing files get `-2`, `-3`… by default; the policy covers a file and its sidecars together; a catalogued original (or its sidecar) is never written over, whatever the policy or an exact `path` (export, `ui.render`, MCP `render_photo`, merge `previewPath`, `lightcraft-cli render`); files are written to a temp file and renamed into place (issue #93; not synced file by file — exports can be made again, issue #134) | @@ -797,7 +797,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | Date | Change | Summary | |---|---|---| -| 2026-10-14 | patch | LR-META-EXIF-FULL, LR-EXP-METADATA: preserve shutter duration through import, display and export (#1619); no catalog schema change. Statuses and feature counts unchanged. | +| 2026-10-14 | patch | LR-META-EXIF-FULL, LR-EXP-METADATA: shutter speeds shown as 1/n or four significant digits; the exact duration is kept in the catalog (optional `exposure_time`, older catalogs read unchanged) and written on export (#1619). Statuses and feature counts unchanged. | | 2026-10-14 | patch | LR-EXP-TYPE: opaque 8-bit PNG/TIFF/WebP use RGB; transparent exports retain alpha (#1670). Statuses and feature counts unchanged. | | 2026-10-15 | minor | LRC-PRINT-PAGE: Page Options (Page Numbers, Page Info, Crop Marks) on Single Image and Contact Sheet pages, in the Print dialog, `print.set` and templates; still 🟡 (no identity plate, watermark, photo info or Cut Guides) | | 2026-10-15 | minor | LR-IMP-FORMATS: Hasselblad 3FR and FFF show their uncompressed RGB preview (no JPEG in these files) in the grid and loupe until developed, and as the stand-in when a file fails to decode; status unchanged (🟡) | From 0c5f3a59fccb9ffdbb265b4638ba7883f4a9c9cc Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 25 Oct 2026 06:33:14 +0100 Subject: [PATCH 3/8] LR-1619: check written 1/N exposure times show as the same text (#2542) --- crates/meta/src/exif.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/meta/src/exif.rs b/crates/meta/src/exif.rs index f24bb5f2fd..b7e2e60862 100644 --- a/crates/meta/src/exif.rs +++ b/crates/meta/src/exif.rs @@ -578,4 +578,14 @@ mod write_tests { assert!((1.0 / got - den).abs() < 0.5, "1/{den} s came back as 1/{}", 1.0 / got); } } + + #[test] + fn written_shutter_speeds_show_as_the_same_reciprocal() { + // #1619 / #2542: the exact time is what export writes, and it reads back as the text shown + for (t, want) in [(1.0 / 3.0, "1/3"), (1.0 / 250.0, "1/250"), (1.0 / 12_800.0, "1/12800"), (0.3, "0.3"), (1.0 / 2.8, "0.3571")] { + let back = read_exif(&write_exif(&Metadata { exposure_time: Some(t), ..Default::default() })); + let got = back.exposure_time.unwrap(); + assert_eq!(crate::format_exposure_time(got).as_deref(), Some(want), "{t} came back as {got}"); + } + } } From 9e74c3a3041076f511e5076b4d1577f202a5c8b8 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 25 Oct 2026 06:53:39 +0100 Subject: [PATCH 4/8] LR-1619: shutter rules match the shown value; Reload from Disk repairs a shutter speed an older import rounded --- crates/catalog/src/rules.rs | 24 +++++++++++++++- crates/engine/src/cmd/convert.rs | 48 ++++++++++++++++++++++++++++++++ docs/parity-checklist.md | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/crates/catalog/src/rules.rs b/crates/catalog/src/rules.rs index ce09b9867d..91724f3441 100644 --- a/crates/catalog/src/rules.rs +++ b/crates/catalog/src/rules.rs @@ -1023,7 +1023,9 @@ impl Rule { "captureDate" => date_op(op, p.captured.as_deref(), value), "importDate" => date_op(op, Some(&p.imported), value), "editDate" => date_op(op, p.edited.as_deref(), value), - "shutterSpeed" => num_op(op, m.shutter_seconds(), &shutter_value(value)), + // (the shown shutter text, not the exact time kept for export: a rule matches the value the + // photo shows, `1/3` or `0.3571`, at every op, including `is` and the edges of a range) + "shutterSpeed" => num_op(op, crate::parse_shutter_seconds(&m.shutter), &shutter_value(value)), "iso" => num_op(op, m.iso.map(|v| v as f64), value), "aperture" => num_op(op, m.aperture.map(f32_as_decimal), value), "focalLength" => num_op(op, m.focal_mm.map(f32_as_decimal), value), @@ -1362,6 +1364,26 @@ mod tests { assert_eq!(field_group("shutterSpeed"), Some("Camera Info")); } + /// A photo whose exact exposure time is kept beside its shown shutter text matches the value it + /// shows: 1/2.8 s shows `0.3571` and is "is 0.3571"; a camera's 3333/10000 s shows `1/3` and is + /// "is 1/3" and inside "≥ 1/3", even though neither exact time equals the shown one. + #[test] + fn shutter_speed_rules_match_the_shown_value() { + let cat = Catalog::new(); + let mut p = photo(1); + let m = |p: &Photo, op: &str, value: serde_json::Value| { + rs(json!({"rules": [{"field": "shutterSpeed", "op": op, "value": value}]})).matches(p, &cat) + }; + p.meta.exposure_time = Some(1.0 / 2.8); + p.meta.shutter = "0.3571".into(); + assert!(m(&p, "is", json!("0.3571")) && !m(&p, "isNot", json!("0.3571")), "1/2.8 s is the 0.3571 it shows"); + assert!(m(&p, "lte", json!("0.3571")) && m(&p, "gte", json!("0.3571"))); + p.meta.exposure_time = Some(3333.0 / 10000.0); + p.meta.shutter = "1/3".into(); + assert!(m(&p, "is", json!("1/3")) && !m(&p, "isNot", json!("1/3")), "3333/10000 s is the 1/3 it shows"); + assert!(m(&p, "gte", json!("1/3")) && m(&p, "lte", json!("1/3")) && !m(&p, "lt", json!("1/3"))); + } + #[test] fn shutter_seconds_parses_camera_notation() { for (s, want) in [("1/250", Some(0.004)), (" 1/250 s", Some(0.004)), ("0.5", Some(0.5)), ("2\"", Some(2.0)), ("30s", Some(30.0))] { diff --git a/crates/engine/src/cmd/convert.rs b/crates/engine/src/cmd/convert.rs index 6da798136c..7232fa5d1e 100644 --- a/crates/engine/src/cmd/convert.rs +++ b/crates/engine/src/cmd/convert.rs @@ -236,6 +236,15 @@ fn fill_missing_meta(id: lightcraft_catalog::PhotoId, ph: &lightcraft_catalog::P if m.shutter.is_empty() { m.shutter = src.shutter.clone(); m.exposure_time = src.exposure_time; + } else if m.exposure_time.is_none() + && let Some(t) = src.exposure_time + && (m.shutter.trim() == src.shutter || legacy_shutter_text(t).is_some_and(|old| m.shutter.trim() == old)) + { + // a photo imported before the exact time was kept: its shutter text is still the one import + // wrote then (rounded: 0.4 s as `1/2`, 2.5 s as `2`), so it takes the file's exact time and the + // text shown for it now; a shutter speed typed by hand that the file doesn't give is kept + m.shutter = src.shutter.clone(); + m.exposure_time = Some(t); } m.focal_mm = m.focal_mm.or(src.focal_mm); m.aperture = m.aperture.or(src.aperture); @@ -255,6 +264,12 @@ fn fill_missing_meta(id: lightcraft_catalog::PhotoId, ph: &lightcraft_catalog::P ops } +/// The shutter text an import wrote before the exact exposure time was kept (#1619): whole seconds at +/// one second and over, otherwise `1/n` with `n` rounded. Only for recognising such a text again. +fn legacy_shutter_text(t: f64) -> Option { + (t.is_finite() && t > 0.0).then(|| if t >= 1.0 { format!("{t:.0}") } else { format!("1/{:.0}", 1.0 / t) }) +} + /// Ops that give a photo the lens data its file carries now (`info`, a fresh probe), or none when /// it already has them. A catalog from before the lens data was read at import has none, so such a /// photo's correction stayed off. When the photo gains lens data and its develop settings are still @@ -431,6 +446,39 @@ mod tests { assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty()); } + /// Reload from Disk repairs a shutter speed an older import rounded (0.4 s stored as `1/2`, with no + /// exact time): the photo takes the file's exact time and today's text. A shutter speed set by hand + /// that is not what an import wrote, and one that already has its exact time, are kept. + #[test] + fn reload_repairs_a_shutter_speed_an_older_import_rounded() { + let mut ph = Photo::new(PhotoId(1), Source::File { path: "/x.nef".into() }, "x.nef", "NEF", 6000, 4000, "2026-10-06T00:00:00"); + ph.captured = Some("2026-10-04T08:16:11".into()); + let mut info = crate::media::ProbeInfo { captured: ph.captured.clone(), ..Default::default() }; + for (t, legacy, shown) in [(0.4, "1/2", "0.4"), (2.5, "2", "2.5"), (1.0 / 2.8, "1/3", "0.3571"), (1.0 / 250.0, "1/250", "1/250")] { + info.meta.exposure_time = Some(t); + info.meta.shutter = lightcraft_meta::format_exposure_time(t).unwrap(); + ph.meta.shutter = legacy.into(); + ph.meta.exposure_time = None; + let ops = fill_missing_meta(PhotoId(1), &ph, &info); + let Some(Op::SetMeta { meta, .. }) = ops.first() else { panic!("{t}: {ops:?}") }; + assert_eq!((meta.shutter.as_str(), meta.exposure_time), (shown, Some(t)), "{t}"); + assert_eq!(meta.shutter_seconds(), Some(t), "{t}"); + // repaired → nothing more to do + ph.meta = (**meta).clone(); + assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty(), "{t}"); + } + // typed by hand, not what any import wrote for this file + info.meta.exposure_time = Some(0.4); + info.meta.shutter = "0.4".into(); + ph.meta.shutter = "1/8".into(); + ph.meta.exposure_time = None; + assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty(), "a hand-set shutter speed is kept"); + // already has an exact time (the text was edited afterwards): kept + ph.meta.shutter = "1/2".into(); + ph.meta.exposure_time = Some(0.4); + assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty(), "a photo with an exact time is left alone"); + } + /// Reload from Disk gives a photo imported before focus points were read its camera focus point, /// and never replaces one it has. #[test] diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 2e2ff2a116..aab955da44 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -398,7 +398,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EXP-COLORSPACE | Output colour space | P0 | ✅ | `cmd:app.export` (`colorSpace`), `crates/pipeline/src/output.rs`, `crates/engine/src/export.rs` | sRGB, Display P3, Adobe RGB (1998) compatible, ProPhoto RGB, Rec. 2020: rendered from the working space with gamut mapping into the target gamut (CPU + GPU), own ICC profile embedded; AVIF stays sRGB (muxer has no ICC); lossy JPEG XL declares sRGB / P3 / Rec. 2020 (Adobe RGB and ProPhoto written as Rec. 2020), lossless JPEG XL embeds the profile | | LR-EXP-HDR | HDR output | P2 | 🟡 | `cmd:app.export`, `crates/ui-egui/src/panels/dialogs.rs` | HDR output checkbox in the export dialog: gain map JPEG, PQ or HLG AVIF, PQ PNG, PQ JPEG XL, float TIFF; no HDR presets yet | | LR-EXP-SHARPEN | Output sharpening | P1 | ✅ | `cmd:app.export` (`sharpen`, `sharpenAmount`) | | -| LR-EXP-METADATA | Metadata policy | P1 | ✅ | `cmd:app.export` (`metadata`, `removeLocation`) | Export writes the exact exposure time kept in the catalog beside the rounded shutter text (#1619); previously rounded catalog values require reloading metadata from the original. | +| LR-EXP-METADATA | Metadata policy | P1 | ✅ | `cmd:app.export` (`metadata`, `removeLocation`) | Export writes the exact exposure time kept in the catalog beside the rounded shutter text (#1619); a photo imported earlier, whose shutter text is still the rounded one import wrote then, gets the exact time and current text from Reload from Disk; a shutter speed set by hand is kept. Smart-album Shutter Speed rules compare the shown value. | | LR-EXP-WATERMARK | Watermark | P1 | 🟡 | `cmd:app.export` (`watermark`: text, or `{text, vertical, size, opacity, anchor, insetX, insetY, inset, rotation, color, shadow, image, imageWidth}`), `crates/engine/src/export.rs` (`Watermark`, `WATERMARK_PARAMS`) | text uses Inter SemiBold, the existing Mincho-first CJK chain, then Thai faces from `CRAFT_FONTS_DIR`, shared with contact-sheet captions and slideshow overlays (#2052, partial). Horizontal Thai mark positioning remains incomplete. Arabic export fallback is deferred until joining and bidi reordering exist; UI font fallback is unchanged. Text (`size` = height as a fraction of the short edge, 0.005..0.5, default 0.035; `color` sRGB `[r,g,b]`; `shadow`; Japanese vertical glyph forms and origins, tested by `biz_ud_vertical_watermarks_place_punctuation_at_the_top_right`; extended grapheme cells keep decomposed dakuten/handakuten and Latin accents together, tested by `vertical_watermarks_keep_combining_marks_in_one_cell` and `upright_watermark_cell_retains_multiple_glyphs` (see `docs/vertical-watermarks.md`)) or a graphic with transparency (EXIF orientation applied before sizing; oversized graphics fit the rotated image bounds without stretching, tested by `graphic_watermark_honours_exif_orientation` and `graphic_watermark_keeps_aspect_when_fitted_and_rotated`; `image` path, `imageWidth` = fraction of the photo's width, 0.01..1, converted to the output colour space); `anchor` (nine positions), `insetX` / `insetY` (margins from the side and from the top/bottom edges, each a fraction of the short edge, 0..0.4; the Export dialog's Horizontal and Vertical inset sliders, as in Lightroom Classic; the older single `inset` still reads as both; tested by `watermark_insets_are_horizontal_and_vertical`), `rotation` (0, 90, 180 or 270 degrees clockwise, the Export dialog's Rotate row, as Lightroom Classic's rotate buttons; sized before it is turned, placed and inset by the turned box; tested by `watermark_rotation_turns_the_text_in_its_corner` and `graphic_watermark_is_placed_scaled_and_blended`), `opacity` 0..1. Unknown keys and out-of-range values are errors (issue #183). The Export dialog previews it on the first exported photo's thumbnail (`draw_watermark_preview` scales the 6 px minimum text size to the preview so it matches the file), tested by `watermark_preview_scales_the_minimum_text_size` and `export_dialog_previews_the_watermark` | | LR-EXP-NAMING | File naming | P1 | ✅ | `cmd:app.export` (`naming`, `startNumber`), `crates/engine/src/rename.rs` (`expand_tokens`) | one template language for export, Rename Photos and import renaming: `{name}`, `{num}` (number at the end of the name), `{seq}` / `{seq:N}`, `{date}` / `{date:%Y-%m-%d}`, `{folder}`, `{camera}`, `{lens}`, `{iso}`, `{rating}`, `{title}`, `{creator}`, `{ext}`; free-form template rather than a list of named schemes | | LR-EXP-LOCATION | Destination folder | P0 | ✅ | `cmd:app.export` (`dir`, `destinationMode`: specificFolder / sameAsOriginal, `subfolder`, `conflict`: unique / overwrite / skip), `cmd:export.checkTarget`, `crates/ui-egui/src/panels/dialogs.rs` (Choose… folder picker), `crates/engine/src/originals.rs`, `crates/catalog/src/safe_file.rs` | folder picker on the desktop; Export to: Specific folder or Same folder as original photo (each photo into its original's folder + the subfolder; a demo/browser photo or a missing folder is that photo's error, issue #956); existing files get `-2`, `-3`… by default; the policy covers a file and its sidecars together; a catalogued original (or its sidecar) is never written over, whatever the policy or an exact `path` (export, `ui.render`, MCP `render_photo`, merge `previewPath`, `lightcraft-cli render`); files are written to a temp file and renamed into place (issue #93; not synced file by file — exports can be made again, issue #134) | From 467b36616a310f5c81b5c63fd2e2ce0d71177c49 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Fri, 30 Oct 2026 08:18:55 +0100 Subject: [PATCH 5/8] Format relocated shutter-rule regression --- crates/catalog/src/rules/tests.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/catalog/src/rules/tests.rs b/crates/catalog/src/rules/tests.rs index aad006f916..c2945f1966 100644 --- a/crates/catalog/src/rules/tests.rs +++ b/crates/catalog/src/rules/tests.rs @@ -779,9 +779,8 @@ fn file_path_contains_finds_every_piece_of_a_long_path() { fn shutter_speed_rules_match_the_shown_value() { let cat = Catalog::new(); let mut p = photo(1); - let m = |p: &Photo, op: &str, value: serde_json::Value| { - rs(json!({"rules": [{"field": "shutterSpeed", "op": op, "value": value}]})).matches(p, &cat) - }; + let m = + |p: &Photo, op: &str, value: serde_json::Value| rs(json!({"rules": [{"field": "shutterSpeed", "op": op, "value": value}]})).matches(p, &cat); p.meta.exposure_time = Some(1.0 / 2.8); p.meta.shutter = "0.3571".into(); assert!(m(&p, "is", json!("0.3571")) && !m(&p, "isNot", json!("0.3571")), "1/2.8 s is the 0.3571 it shows"); From 5d84788f281e3702b8885cee61ad3e14705a0c4f Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Fri, 30 Oct 2026 08:49:42 +0100 Subject: [PATCH 6/8] Track the update prompt's embedded app icon in quick CI Main now embeds the app icon in lightcraft-ui-egui as well as the desktop host. Preserve the completeness guard and add a regression for both consumers rather than bypass the failing gate. --- xtask/src/ci_quick.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xtask/src/ci_quick.rs b/xtask/src/ci_quick.rs index f187daf59e..940ad6451e 100644 --- a/xtask/src/ci_quick.rs +++ b/xtask/src/ci_quick.rs @@ -33,7 +33,7 @@ const HEIF_PACKAGES: &[&str] = &["lightcraft-codecs", "lightcraft-heif"]; /// a build script's `rerun-if-changed`): a change to one counts as a change to those packages. /// An entry ending in `/` covers the directory. `embedded_files_are_mapped` keeps this complete. const EMBEDDED: &[(&str, &[&str])] = &[ - ("assets/app-icon/", &["lightcraft"]), + ("assets/app-icon/", &["lightcraft", "lightcraft-ui-egui"]), ("assets/camera-profiles/", &["lightcraft-engine"]), ("assets/camera-tone/", &["lightcraft-engine"]), ("assets/fonts/", &["lightcraft-engine", "lightcraft-ui-egui"]), @@ -272,6 +272,12 @@ mod tests { assert!(!p.rust(), "only files something compiles in"); } + #[test] + fn app_icon_changes_retest_both_hosts_and_the_update_prompt() { + let users: Vec<_> = embedders("assets/app-icon/hicolor/128x128/apps/ai.storyteller.lightcraft.png").collect(); + assert_eq!(users, ["lightcraft", "lightcraft-ui-egui"]); + } + /// Every `include_str!` / `include_bytes!` of a file outside its package, and every `"../…"` /// path in a build script, is listed in `EMBEDDED` for that package. #[test] From e686c73109ee7cf1eb0b0dc037ced68502f60f37 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:32:20 +0100 Subject: [PATCH 7/8] fix: repair legacy shutter values in virtual copies --- crates/engine/src/cmd/convert.rs | 96 +++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 21 deletions(-) diff --git a/crates/engine/src/cmd/convert.rs b/crates/engine/src/cmd/convert.rs index 342f7ad2c4..57ee169528 100644 --- a/crates/engine/src/cmd/convert.rs +++ b/crates/engine/src/cmd/convert.rs @@ -10,7 +10,7 @@ use serde_json::{Value, json}; use super::{CommandSpec, bad, cmd, has_active, has_selection}; use crate::{Result, Session}; -/// `.dng`, then `-2.dng`, `-3.dng`… next to `path`. +/// `.dng`, then `-2.dng`, `-3.dng`ΓǪ next to `path`. fn dng_names(path: &str) -> impl Iterator { let p = Path::new(path); let dir = p.parent().unwrap_or(Path::new("")).to_path_buf(); @@ -23,7 +23,7 @@ fn dng_names(path: &str) -> impl Iterator { /// /// The DNG is checked before anyone relies on it (Convert to DNG relinks the photo to it, Copy as /// DNG deletes the raw copy): the encoded file must decode to the same raw data, and it is -/// written to a temp file, synced, read back identical and only then given its name — never +/// written to a temp file, synced, read back identical and only then given its name ΓÇö never /// replacing an existing file. On any failure no DNG is left behind and the raw stays in use. pub(crate) fn write_dng_for(s: &Session, path: &str, packet: String) -> std::result::Result { write_dng_with(s.media.file_bytes.as_ref(), path, packet) @@ -114,7 +114,7 @@ pub fn specs() -> Vec { "Convert to DNG", ["Photo"], None, - "{ids?} — write each raw photo as a lossless DNG next to it (settings embedded) and relink the photo to it; originals are kept → {converted: [{id, path, original}], skipped}", + "{ids?} ΓÇö write each raw photo as a lossless DNG next to it (settings embedded) and relink the photo to it; originals are kept ΓåÆ {converted: [{id, path, original}], skipped}", has_selection, convert )] @@ -242,15 +242,8 @@ fn fill_missing_meta(id: lightcraft_catalog::PhotoId, ph: &lightcraft_catalog::P if m.shutter.is_empty() { m.shutter = src.shutter.clone(); m.exposure_time = src.exposure_time; - } else if m.exposure_time.is_none() - && let Some(t) = src.exposure_time - && (m.shutter.trim() == src.shutter || legacy_shutter_text(t).is_some_and(|old| m.shutter.trim() == old)) - { - // a photo imported before the exact time was kept: its shutter text is still the one import - // wrote then (rounded: 0.4 s as `1/2`, 2.5 s as `2`), so it takes the file's exact time and the - // text shown for it now; a shutter speed typed by hand that the file doesn't give is kept - m.shutter = src.shutter.clone(); - m.exposure_time = Some(t); + } else { + repair_legacy_shutter(&mut m, src); } m.focal_mm = m.focal_mm.or(src.focal_mm); m.aperture = m.aperture.or(src.aperture); @@ -275,6 +268,20 @@ fn fill_missing_meta(id: lightcraft_catalog::PhotoId, ph: &lightcraft_catalog::P ops } +/// Repair only the shutter data an old import wrote, keeping independently edited metadata. +fn repair_legacy_shutter(m: &mut lightcraft_catalog::Meta, src: &lightcraft_catalog::Meta) -> bool { + if m.exposure_time.is_none() + && let Some(t) = src.exposure_time + && (m.shutter.trim() == src.shutter || legacy_shutter_text(t).is_some_and(|old| m.shutter.trim() == old)) + { + m.shutter = src.shutter.clone(); + m.exposure_time = Some(t); + true + } else { + false + } +} + /// The shutter text an import wrote before the exact exposure time was kept (#1619): whole seconds at /// one second and over, otherwise `1/n` with `n` rounded. Only for recognising such a text again. fn legacy_shutter_text(t: f64) -> Option { @@ -330,8 +337,16 @@ pub(crate) fn reload_ops( } // virtual copies share the file for c in cat.photos().filter(|c| c.copy_of == Some(id)) { - let theirs: Vec = - content_op(c.id, c, info.clone()).into_iter().chain(lens_ops(c.id, c, info)).chain(as_shot_wb_op(c.id, c, info)).collect(); + let mut meta = c.meta.clone(); + // Copies share the source file but may have independently edited metadata. Repair only + // recognizable legacy shutter values, not every missing field on the copy. + let shutter_op = repair_legacy_shutter(&mut meta, &info.meta).then(|| Op::SetMeta { id: c.id, meta: Box::new(meta) }); + let theirs: Vec = content_op(c.id, c, info.clone()) + .into_iter() + .chain(shutter_op) + .chain(lens_ops(c.id, c, info)) + .chain(as_shot_wb_op(c.id, c, info)) + .collect(); if !theirs.is_empty() { ops.extend(theirs); changed.push(c.id); @@ -341,7 +356,7 @@ pub(crate) fn reload_ops( /// Re-read photos whose files changed on disk (an external editor saved them): new size, /// dimensions and content hash, cached sources dropped. The app runs the same steps -/// ([`crate::cmd::reload`]) with the files read on a worker thread. → {reloaded: [ids]} +/// ([`crate::cmd::reload`]) with the files read on a worker thread. ΓåÆ {reloaded: [ids]} fn reload(s: &mut Session, p: &Value) -> Result { use crate::cmd::reload as r; let items = r::plan(s, p)?; @@ -352,7 +367,7 @@ fn reload(s: &mut Session, p: &Value) -> Result { } /// Duplicate: copy the file next to itself (`-copy`, never overwriting) and add it with the -/// same settings, metadata, rating, flag, label and albums. → {ids} +/// same settings, metadata, rating, flag, label and albums. ΓåÆ {ids} fn duplicate(s: &mut Session, p: &Value) -> Result { const C: &str = "photo.duplicate"; let mut made = Vec::new(); @@ -404,7 +419,7 @@ pub fn edit_specs() -> Vec { "Duplicate", ["Photo"], None, - "{ids?} — copy each photo's file next to it (`-copy`) and add it with the same settings, metadata and albums (a real file, unlike a virtual copy) → {ids}", + "{ids?} ΓÇö copy each photo's file next to it (`-copy`) and add it with the same settings, metadata and albums (a real file, unlike a virtual copy) ΓåÆ {ids}", has_selection, duplicate ), @@ -413,7 +428,7 @@ pub fn edit_specs() -> Vec { "Reload from Disk", ["Photo"], None, - "{ids?} — re-read photos whose files changed on disk (e.g. saved by an external editor), or raws shown from their embedded preview that can be decoded now; camera fields the catalog lacks are filled in, and so is the lens data the file carries (an untouched photo then gets its lens correction turned on as import would; an edited one keeps its settings); in the app the files are read in the background (activity row `reload`, cancellable) and the reply is {background: true, count} unless `wait: true` → {reloaded}", + "{ids?} ΓÇö re-read photos whose files changed on disk (e.g. saved by an external editor), or raws shown from their embedded preview that can be decoded now; camera fields the catalog lacks are filled in, and so is the lens data the file carries (an untouched photo then gets its lens correction turned on as import would; an edited one keeps its settings); in the app the files are read in the background (activity row `reload`, cancellable) and the reply is {background: true, count} unless `wait: true` ΓåÆ {reloaded}", has_selection, reload ), @@ -422,7 +437,7 @@ pub fn edit_specs() -> Vec { "Edit Copy for External Editor", [], None, - "{ids?, colorSpace?: adobeRgb (default) | proPhoto | displayP3 | srgb, format?: tiff (default) | psd, bitDepth?: 16 (default) | 8, dir?} — render each selected photo (or `ids`, at most 50) with its edits as `-Edit.tif` (or `.psd`, flat, which PhotoCraft saves back to in place) next to it, add each stacked on its original and select the copies → {path, id, original (the first copy), copies: [{path, id, original}]} (the app then opens them in the external editor)", + "{ids?, colorSpace?: adobeRgb (default) | proPhoto | displayP3 | srgb, format?: tiff (default) | psd, bitDepth?: 16 (default) | 8, dir?} ΓÇö render each selected photo (or `ids`, at most 50) with its edits as `-Edit.tif` (or `.psd`, flat, which PhotoCraft saves back to in place) next to it, add each stacked on its original and select the copies ΓåÆ {path, id, original (the first copy), copies: [{path, id, original}]} (the app then opens them in the external editor)", has_active, edit_external ), @@ -451,7 +466,7 @@ mod tests { assert_eq!((meta.camera.as_str(), meta.lens.as_str(), meta.aperture), ("Canon EOS R6 Mark III", "RF24-105mm", Some(6.3))); assert_eq!((meta.title.as_str(), meta.iso), ("Mine", Some(800)), "set fields are kept"); assert!(matches!(ops.get(1), Some(Op::SetCaptured { captured: Some(_), .. }))); - // nothing missing → nothing to do + // nothing missing ΓåÆ nothing to do ph.meta = (**meta).clone(); ph.captured = Some("2026-10-04T08:16:11".into()); assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty()); @@ -474,7 +489,7 @@ mod tests { let Some(Op::SetMeta { meta, .. }) = ops.first() else { panic!("{t}: {ops:?}") }; assert_eq!((meta.shutter.as_str(), meta.exposure_time), (shown, Some(t)), "{t}"); assert_eq!(meta.shutter_seconds(), Some(t), "{t}"); - // repaired → nothing more to do + // repaired ΓåÆ nothing more to do ph.meta = (**meta).clone(); assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty(), "{t}"); } @@ -490,6 +505,45 @@ mod tests { assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty(), "a photo with an exact time is left alone"); } + #[test] + fn reload_repairs_legacy_shutter_on_copies_without_replacing_edits() { + let mut cat = lightcraft_catalog::Catalog::new(); + let mut source = Photo::new(PhotoId(1), Source::File { path: "/x.nef".into() }, "x.nef", "NEF", 6000, 4000, ""); + source.meta.shutter = "1/2".into(); + cat.apply(Op::AddPhoto { photo: Box::new(source.clone()) }).unwrap(); + for (id, text, exact) in [(2, "1/2", None), (3, "0.4", None), (4, "1/8", None), (5, "1/2", Some(0.4))] { + let mut copy = source.clone(); + copy.id = PhotoId(id); + copy.copy_of = Some(source.id); + copy.meta.shutter = text.into(); + copy.meta.exposure_time = exact; + copy.meta.title = "My copy".into(); + cat.apply(Op::AddPhoto { photo: Box::new(copy) }).unwrap(); + } + let mut info = crate::media::ProbeInfo::default(); + info.meta.shutter = "0.4".into(); + info.meta.exposure_time = Some(0.4); + info.meta.title = "File title".into(); + let mut ops = Vec::new(); + let mut changed = Vec::new(); + reload_ops(&cat, source.id, &info, &mut ops, &mut changed); + for op in ops { + cat.apply(op).unwrap(); + } + for id in [1, 2, 3] { + let m = &cat.photo(PhotoId(id)).unwrap().meta; + assert_eq!((m.shutter.as_str(), m.exposure_time), ("0.4", Some(0.4))); + assert_eq!(m.shutter_seconds(), Some(0.4)); + } + for (id, text, exact) in [(4, "1/8", None), (5, "1/2", Some(0.4))] { + let m = &cat.photo(PhotoId(id)).unwrap().meta; + assert_eq!((m.shutter.as_str(), m.exposure_time), (text, exact)); + } + for id in [2, 3, 4, 5] { + assert_eq!(cat.photo(PhotoId(id)).unwrap().meta.title, "My copy"); + } + } + /// Reload from Disk gives a photo imported before focus points were read its camera focus point, /// and never replaces one it has. #[test] From a9ea230a1bbca12b99cc74a0dacdb6e01dd1c77c Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:32:46 +0100 Subject: [PATCH 8/8] fix: preserve existing UTF-8 source comments --- crates/engine/src/cmd/convert.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/cmd/convert.rs b/crates/engine/src/cmd/convert.rs index 57ee169528..af81d3cae4 100644 --- a/crates/engine/src/cmd/convert.rs +++ b/crates/engine/src/cmd/convert.rs @@ -10,7 +10,7 @@ use serde_json::{Value, json}; use super::{CommandSpec, bad, cmd, has_active, has_selection}; use crate::{Result, Session}; -/// `.dng`, then `-2.dng`, `-3.dng`ΓǪ next to `path`. +/// `.dng`, then `-2.dng`, `-3.dng`… next to `path`. fn dng_names(path: &str) -> impl Iterator { let p = Path::new(path); let dir = p.parent().unwrap_or(Path::new("")).to_path_buf(); @@ -23,7 +23,7 @@ fn dng_names(path: &str) -> impl Iterator { /// /// The DNG is checked before anyone relies on it (Convert to DNG relinks the photo to it, Copy as /// DNG deletes the raw copy): the encoded file must decode to the same raw data, and it is -/// written to a temp file, synced, read back identical and only then given its name ΓÇö never +/// written to a temp file, synced, read back identical and only then given its name — never /// replacing an existing file. On any failure no DNG is left behind and the raw stays in use. pub(crate) fn write_dng_for(s: &Session, path: &str, packet: String) -> std::result::Result { write_dng_with(s.media.file_bytes.as_ref(), path, packet) @@ -114,7 +114,7 @@ pub fn specs() -> Vec { "Convert to DNG", ["Photo"], None, - "{ids?} ΓÇö write each raw photo as a lossless DNG next to it (settings embedded) and relink the photo to it; originals are kept ΓåÆ {converted: [{id, path, original}], skipped}", + "{ids?} — write each raw photo as a lossless DNG next to it (settings embedded) and relink the photo to it; originals are kept → {converted: [{id, path, original}], skipped}", has_selection, convert )] @@ -356,7 +356,7 @@ pub(crate) fn reload_ops( /// Re-read photos whose files changed on disk (an external editor saved them): new size, /// dimensions and content hash, cached sources dropped. The app runs the same steps -/// ([`crate::cmd::reload`]) with the files read on a worker thread. ΓåÆ {reloaded: [ids]} +/// ([`crate::cmd::reload`]) with the files read on a worker thread. → {reloaded: [ids]} fn reload(s: &mut Session, p: &Value) -> Result { use crate::cmd::reload as r; let items = r::plan(s, p)?; @@ -367,7 +367,7 @@ fn reload(s: &mut Session, p: &Value) -> Result { } /// Duplicate: copy the file next to itself (`-copy`, never overwriting) and add it with the -/// same settings, metadata, rating, flag, label and albums. ΓåÆ {ids} +/// same settings, metadata, rating, flag, label and albums. → {ids} fn duplicate(s: &mut Session, p: &Value) -> Result { const C: &str = "photo.duplicate"; let mut made = Vec::new(); @@ -419,7 +419,7 @@ pub fn edit_specs() -> Vec { "Duplicate", ["Photo"], None, - "{ids?} ΓÇö copy each photo's file next to it (`-copy`) and add it with the same settings, metadata and albums (a real file, unlike a virtual copy) ΓåÆ {ids}", + "{ids?} — copy each photo's file next to it (`-copy`) and add it with the same settings, metadata and albums (a real file, unlike a virtual copy) → {ids}", has_selection, duplicate ), @@ -428,7 +428,7 @@ pub fn edit_specs() -> Vec { "Reload from Disk", ["Photo"], None, - "{ids?} ΓÇö re-read photos whose files changed on disk (e.g. saved by an external editor), or raws shown from their embedded preview that can be decoded now; camera fields the catalog lacks are filled in, and so is the lens data the file carries (an untouched photo then gets its lens correction turned on as import would; an edited one keeps its settings); in the app the files are read in the background (activity row `reload`, cancellable) and the reply is {background: true, count} unless `wait: true` ΓåÆ {reloaded}", + "{ids?} — re-read photos whose files changed on disk (e.g. saved by an external editor), or raws shown from their embedded preview that can be decoded now; camera fields the catalog lacks are filled in, and so is the lens data the file carries (an untouched photo then gets its lens correction turned on as import would; an edited one keeps its settings); in the app the files are read in the background (activity row `reload`, cancellable) and the reply is {background: true, count} unless `wait: true` → {reloaded}", has_selection, reload ), @@ -437,7 +437,7 @@ pub fn edit_specs() -> Vec { "Edit Copy for External Editor", [], None, - "{ids?, colorSpace?: adobeRgb (default) | proPhoto | displayP3 | srgb, format?: tiff (default) | psd, bitDepth?: 16 (default) | 8, dir?} ΓÇö render each selected photo (or `ids`, at most 50) with its edits as `-Edit.tif` (or `.psd`, flat, which PhotoCraft saves back to in place) next to it, add each stacked on its original and select the copies ΓåÆ {path, id, original (the first copy), copies: [{path, id, original}]} (the app then opens them in the external editor)", + "{ids?, colorSpace?: adobeRgb (default) | proPhoto | displayP3 | srgb, format?: tiff (default) | psd, bitDepth?: 16 (default) | 8, dir?} — render each selected photo (or `ids`, at most 50) with its edits as `-Edit.tif` (or `.psd`, flat, which PhotoCraft saves back to in place) next to it, add each stacked on its original and select the copies → {path, id, original (the first copy), copies: [{path, id, original}]} (the app then opens them in the external editor)", has_active, edit_external ), @@ -466,7 +466,7 @@ mod tests { assert_eq!((meta.camera.as_str(), meta.lens.as_str(), meta.aperture), ("Canon EOS R6 Mark III", "RF24-105mm", Some(6.3))); assert_eq!((meta.title.as_str(), meta.iso), ("Mine", Some(800)), "set fields are kept"); assert!(matches!(ops.get(1), Some(Op::SetCaptured { captured: Some(_), .. }))); - // nothing missing ΓåÆ nothing to do + // nothing missing → nothing to do ph.meta = (**meta).clone(); ph.captured = Some("2026-10-04T08:16:11".into()); assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty()); @@ -489,7 +489,7 @@ mod tests { let Some(Op::SetMeta { meta, .. }) = ops.first() else { panic!("{t}: {ops:?}") }; assert_eq!((meta.shutter.as_str(), meta.exposure_time), (shown, Some(t)), "{t}"); assert_eq!(meta.shutter_seconds(), Some(t), "{t}"); - // repaired ΓåÆ nothing more to do + // repaired → nothing more to do ph.meta = (**meta).clone(); assert!(fill_missing_meta(PhotoId(1), &ph, &info).is_empty(), "{t}"); }