Skip to content

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

Merge PR #1590

Brandon Thomasbde5385a6f09
diff --cc crates/meta/src/exif.rs
index 2ce5ff1a2,4255c4d50..767da14e6
--- a/crates/meta/src/exif.rs
+++ b/crates/meta/src/exif.rs
@@@ -144,114 -142,64 +148,167 @@@ fn read_gps(g: &Ifd) -> Option<Gps>
Some(Gps { latitude: lat, longitude: lon, altitude })
}
+/// Panasonic maker note tag `0x0051` (LensType in the ExifTool Panasonic tag names): the lens name, ASCII.
+const PANASONIC_LENS_TYPE: u16 = 0x0051;
+/// RW2/RWL IFD0 tag `0x002E` (JpgFromRaw): a JPEG whose APP1 holds the full Exif, maker note included.
+const PANASONIC_JPG_FROM_RAW: u16 = 0x002E;
+
+/// The lens name in the Panasonic maker note (tag `0x0051`) of this Exif or RW2 stream (`data` starts at its
+/// TIFF header): the note of its own Exif IFD, else, for a raw, the note in its JpgFromRaw's Exif.
+pub(crate) fn panasonic_maker_note_lens(data: &[u8], tiff: &Tiff) -> Option<String> {
+ panasonic_lens(data, tiff).or_else(|| panasonic_jpg_from_raw_lens(tiff))
+}
+
+/// The lens name in a `Panasonic\0` maker note of this Exif stream (`data` starts at its TIFF header).
+fn panasonic_lens(data: &[u8], tiff: &Tiff) -> Option<String> {
+ let exif = tiff.exif()?;
+ if !exif.bytes(t::MAKER_NOTE)?.starts_with(b"Panasonic\0") {
+ return None;
+ }
+ let e = exif.get(t::MAKER_NOTE)?;
+ let make = tiff.ifds.first().and_then(|i| i.string(t::MAKE)).unwrap_or_default();
+ let mn = lightcraft_tiff::makernote::parse_makernote(data, e.offset, e.count() as u64, tiff.order, &make)?;
+ text(Some(&mn.ifd), PANASONIC_LENS_TYPE)
+}
+
+/// The lens name from the Exif of a RW2's (or Leica RWL's) embedded JpgFromRaw.
+fn panasonic_jpg_from_raw_lens(tiff: &Tiff) -> Option<String> {
+ let jpg = tiff.ifds.first()?.bytes(PANASONIC_JPG_FROM_RAW)?;
+ let exif = crate::jpeg_segments(jpg).exif?;
+ let data = strip_exif_header(&exif);
+ panasonic_lens(data, &Tiff::parse(data).ok()?)
+}
+
+ /// Nikon maker note tag `0x0084` (Lens in the ExifTool Nikon tag names): shortest and longest focal length, then the
+ /// widest aperture at each, as rationals, like Exif LensSpecification. Zero for a lens that doesn't report itself.
+ const NIKON_LENS: u16 = 0x0084;
+
+ /// The lens a Nikon camera records in its maker note, when it's plausible.
+ fn nikon_lens_spec(exif: Option<&Ifd>, make: Option<&str>, order: lightcraft_tiff::ByteOrder) -> Option<[f64; 4]> {
+ let make = make?;
+ if !make.trim().to_ascii_uppercase().starts_with("NIKON") {
+ return None;
+ }
+ let note = exif?.bytes(t::MAKER_NOTE)?;
+ let mn = lightcraft_tiff::makernote::parse_makernote(note, 0, note.len() as u64, order, make)?;
+ let s = mn.ifd.f64s(NIKON_LENS)?;
+ let [short, long, wide, narrow] = s.as_slice() else { return None };
+ let focal = |f: f64| f.is_finite() && f > 0.0 && f < 10_000.0;
+ let aperture = |a: f64| a.is_finite() && a > 0.0 && a < 100.0;
+ (focal(*short) && focal(*long) && long >= short && aperture(*wide) && aperture(*narrow)).then_some([*short, *long, *wide, *narrow])
+ }
+
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use lightcraft_tiff::{ByteOrder, IfdBuilder, TiffWriter, Value};
+ /// An Exif block from a Panasonic body: no LensModel, the lens name in maker note tag 0x0051, whose value
+ /// lies outside the note's IFD at an offset relative to the Exif TIFF header (as Panasonic writes it).
+ pub(crate) fn panasonic_exif(order: ByteOrder, lens: Option<&str>, lens_model: Option<&str>) -> Vec<u8> {
+ let note = |at: u32| {
+ let mut v = b"Panasonic\0\0\0".to_vec();
+ order.put_u16(&mut v, 1);
+ order.put_u16(&mut v, if lens.is_some() { PANASONIC_LENS_TYPE } else { 0x0001 });
+ order.put_u16(&mut v, 2);
+ let name = format!("{:<34}\0", lens.unwrap_or("0210"));
+ order.put_u32(&mut v, name.len() as u32);
+ order.put_u32(&mut v, at + 30);
+ order.put_u32(&mut v, 0);
+ v.extend_from_slice(name.as_bytes());
+ v
+ };
+ let build = |at: u32| {
+ let mut exif = IfdBuilder::new();
+ exif.set(t::MAKER_NOTE, Value::Undefined(note(at)));
+ exif.set(t::FOCAL_LENGTH, Value::Rational(vec![(25, 1)]));
+ if let Some(l) = lens_model {
+ exif.set(t::LENS_MODEL, Value::Ascii(l.into()));
+ }
+ let mut ifd0 = IfdBuilder::new();
+ ifd0.set(t::MAKE, Value::Ascii("Panasonic".into()));
+ ifd0.set_child(t::EXIF_IFD, exif);
+ TiffWriter::new(order, false).write(&[ifd0]).unwrap()
+ };
+ // the note's own offset is only known once it is laid out; its length doesn't change
+ let first = build(0);
+ let at = Tiff::parse(&first).unwrap().exif().unwrap().get(t::MAKER_NOTE).unwrap().offset as u32;
+ build(at)
+ }
+
+ #[test]
+ fn panasonic_maker_note_names_the_lens() {
+ for order in [ByteOrder::Little, ByteOrder::Big] {
+ let m = read_exif(&panasonic_exif(order, Some("LUMIX G 25/F1.7"), None));
+ assert_eq!(m.lens_model.as_deref(), Some("LUMIX G 25/F1.7"));
+ assert_eq!(m.focal_length, Some(25.0));
+ }
+ // Exif's own LensModel wins, and a note without 0x0051 leaves the lens empty
+ let m = read_exif(&panasonic_exif(ByteOrder::Little, Some("LUMIX G 25/F1.7"), Some("Other 25mm")));
+ assert_eq!(m.lens_model.as_deref(), Some("Other 25mm"));
+ assert_eq!(read_exif(&panasonic_exif(ByteOrder::Little, None, None)).lens_model, None);
+ }
+
+ /// A RW2 has the full Exif only in the APP1 of its JpgFromRaw (IFD0 0x002E), not in its own Exif IFD.
+ pub(crate) fn panasonic_rw2(lens: &str) -> Vec<u8> {
+ let mut jpg = vec![0xff, 0xd8, 0xff, 0xe1];
+ let mut app1 = b"Exif\0\0".to_vec();
+ app1.extend(panasonic_exif(ByteOrder::Little, Some(lens), None));
+ jpg.extend_from_slice(&((app1.len() + 2) as u16).to_be_bytes());
+ jpg.extend(app1);
+ jpg.extend_from_slice(&[0xff, 0xda, 0, 2, 0xff, 0xd9]);
+ let mut exif = IfdBuilder::new();
+ exif.set(t::FOCAL_LENGTH, Value::Rational(vec![(85, 1)]));
+ let mut ifd0 = IfdBuilder::new();
+ ifd0.set(t::MAKE, Value::Ascii("Panasonic".into()));
+ ifd0.set(PANASONIC_JPG_FROM_RAW, Value::Undefined(jpg));
+ ifd0.set_child(t::EXIF_IFD, exif);
+ TiffWriter::new(ByteOrder::Little, false).write(&[ifd0]).unwrap()
+ }
+
+ #[test]
+ fn rw2_reads_the_lens_from_its_jpg_from_raw() {
+ let rw2 = panasonic_rw2("LUMIX S 85/F1.8");
+ let m = read_exif(&rw2);
+ assert_eq!(m.lens_model.as_deref(), Some("LUMIX S 85/F1.8"));
+ assert_eq!(m.focal_length, Some(85.0));
+ assert_eq!(crate::extract(&rw2).lens_model.as_deref(), Some("LUMIX S 85/F1.8"));
+ }
+
+ /// An Exif block from a Nikon body whose maker note records the lens (tag 0x0084) and no LensModel or
+ /// LensSpecification, as the D700, D750, D80 and D5300 write it.
+ fn nikon_exif(make: &str, lens: Option<[(u32, u32); 4]>, spec: Option<[(u32, u32); 4]>) -> Vec<u8> {
+ let mut note = IfdBuilder::new();
+ note.set(0x0001, Value::Undefined(b"0210".to_vec()));
+ if let Some(l) = lens {
+ note.set(NIKON_LENS, Value::Rational(l.to_vec()));
+ }
+ let mut blob = b"Nikon\0\x02\x10\0\0".to_vec();
+ blob.extend(TiffWriter::new(ByteOrder::Little, false).write(&[note]).unwrap());
+ let mut exif = IfdBuilder::new();
+ exif.set(t::MAKER_NOTE, Value::Undefined(blob));
+ if let Some(sp) = spec {
+ exif.set(t::LENS_SPECIFICATION, Value::Rational(sp.to_vec()));
+ }
+ let mut ifd0 = IfdBuilder::new();
+ ifd0.set(t::MAKE, Value::Ascii(make.into()));
+ ifd0.set_child(t::EXIF_IFD, exif);
+ TiffWriter::new(ByteOrder::Big, false).write(&[ifd0]).unwrap()
+ }
+
+ #[test]
+ fn nikon_maker_note_lens_fills_the_lens_spec() {
+ let zoom = [(18, 1), (135, 1), (35, 10), (56, 10)];
+ assert_eq!(read_exif(&nikon_exif("NIKON CORPORATION", Some(zoom), None)).lens_spec, Some([18.0, 135.0, 3.5, 5.6]));
+ // Exif's own LensSpecification wins, another make's note is not read, and a lens that reports nothing is left out
+ let prime = [(50, 1), (50, 1), (18, 10), (18, 10)];
+ assert_eq!(read_exif(&nikon_exif("NIKON CORPORATION", Some(zoom), Some(prime))).lens_spec, Some([50.0, 50.0, 1.8, 1.8]));
+ assert_eq!(read_exif(&nikon_exif("Canon", Some(zoom), None)).lens_spec, None);
+ assert_eq!(read_exif(&nikon_exif("NIKON CORPORATION", Some([(0, 1), (0, 1), (0, 1), (0, 1)]), None)).lens_spec, None);
+ assert_eq!(read_exif(&nikon_exif("NIKON CORPORATION", Some([(200, 1), (80, 1), (28, 10), (28, 10)]), None)).lens_spec, None);
+ assert_eq!(read_exif(&nikon_exif("NIKON CORPORATION", None, None)).lens_spec, None);
+ }
+
pub(crate) fn sample_exif(order: ByteOrder) -> Vec<u8> {
let mut exif = IfdBuilder::new();
exif.set(t::EXPOSURE_TIME, Value::Rational(vec![(1, 250)]));
diff --cc docs/parity-checklist.md
index ef23dbe37,750c7b1c9..1cf129ab8
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@@ -833,17 -812,10 +833,18 @@@ Latin stays upright. Advanced Japanese
| 2026-10-12 | minor | LR-IMP-FORMATS: the Hasselblad Lunar (a Sony NEX-7 ARW under Make HASSELBLAD) decodes from sensor data instead of opening as its preview; an uncompressed Leaf MOS imports as a preview-only raw instead of a greyscale image of its mosaic (#1275); status unchanged (🟡) |
| 2026-10-12 | minor | LR-HDR-EXPORT, LR-EXP-HDR: HLG AVIF export (`hdrTransfer`); LR-VIEW-HDR-DISPLAY: tested SDR/HDR display decision |
| 2026-10-12 | minor | LR-EXP-PSD, MENU-FILE-PHOTOSHOP: Photo ▸ Edit In ▸ Open Original in Other Editor (RAW, no copy) hands the original files (the raws themselves) to the other editor in one start; statuses unchanged |
+| 2026-10-12 | minor | LR-MASK-BRUSH: pen pressure scales brush size and flow |
| 2026-10-13 | patch | LR-BEHAV-AUTOSAVE: a damaged snapshot that still parses is repaired on open (ids, stacks, folder loops, id counters) instead of panicking or hanging; status unchanged |
| 2026-10-13 | minor | LR-EDIT-OPTICS-PROFILE: Nikon Z 6II / Z 8 / Z f NEFs use the camera's in-file distortion correction (NikonNEFInfo); status unchanged (🟡) |
+| 2026-10-12 | minor | LR-IMP-FORMATS and LR-IMP-CAMERA-COVERAGE: 22 more CR3 bodies verified on one CC0 file each (all 110 CC0 CR3s decode); EOS R6 Mark III `ColorData` 66 white balance; status unchanged (🟡: CRX variants without public samples remain refused) |
| 2026-10-11 | minor | Model setup folder action, opener error and retry (LR-MASK-OBJECTS). |
+| 2026-10-12 | minor | LR-VIEW-ZOOM: slider-drag drafts are timed with the frame that shows them, drop to 0.6 mid-drag when far over budget, stay 0.6 under a zoom window; workers convert texture pixels (issue #330); status unchanged |
+| 2026-10-11 | minor | LR-VIEW-ZOOM: a slider drag keeps the loupe's full resolution where the GPU draws the view and keeps up (0.6 drafts on the CPU, with soft proofing or the HDR range, or after over-budget drags; issue #330); status unchanged |
+| 2026-10-11 | minor | LR-EXP-LOCATION: Export to "Same folder as original photo" (`destinationMode`), issue #956; status unchanged (✅) |
+| 2026-10-12 | minor | LR-IMP-CAMERA-COVERAGE: 117 Nikon and Fujifilm Adobe models verified on one CC0 file each; COOLPIX 5700 / 8400 / 8800 found decoding wrongly; status unchanged (🟡) |
+| 2026-10-13 | patch | LR-EXP-QUALITY: JPEG exports use Huffman tables made for each image (same pixels, 12–14 % smaller files, issue #1373); status unchanged |
+| 2026-10-13 | patch | LR-BEHAV-GPU: a GPU lost while LightCraft runs (driver reset) is reported as a stop, not a failed start, and the next start renders on the CPU and says why (issue #1337); status unchanged |
+ | 2026-10-13 | minor | LR-META-INFO: Nikon DSLR raws show their lens from the maker note; status unchanged (✅) |
| 2026-10-11 | minor | KEY-SLIDER-TYPE: honor immediate Return/Escape and keep typed keys in the value editor; add regression references |
| 2026-10-11 | minor | LR-PROF-CAMERACOLOR: raws with a black-and-white camera JPEG take its tone curve (issue #577) |
| 2026-10-11 | minor | LR-VIEW-ZOOM and LR-VIEW-COMPARE: Compare and Reference are sharp at 1:1 (zoom windows per pane, two originals kept decoded while they are open); statuses unchanged |
diff --cc docs/whats-new.md
index 62d1a3c9d,0faaa8b3a..646f43434
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@@ -1,80 -1,13 +1,86 @@@
# What's new in LightCraft
+## 2026-10-15
+
+### Lightroom radial masks on the right side
+- Radial masks brought over from Lightroom Classic (catalog import, XMP sidecars, edits inside DNGs and presets) now
+ apply their effect inside the circle, as Lightroom does, instead of outside it (issue #1815). A mask inverted in
+ Lightroom stays inverted, and older Radial Filters keep their Effect Outside / Invert Mask setting. Photos imported
+ before this keep the masks they got: Photo ▸ Read Metadata from File reads a sidecar's again.
+
+## 2026-10-15
+
+### Delete in an album removes from the album only
+- In an album, the Delete key now takes the selected photos out of the album, as in Lightroom. It used to move them
+ to Recently Deleted, so they also left their folder's view (issue #1805). They stay in the library and in their
+ folder; Edit ▸ Undo puts them back in the album. Photo ▸ Remove from Album does the same and now shows the key.
+ To delete photos from the library from an album, use Photo ▸ Delete Photo or right-click ▸ Delete Photo. In a smart
+ album, Delete changes nothing: its rules decide what it shows.
+
## 2026-10-14
+### HDR merges of moving lights, and many brackets at once
+- A star, the moon or a light that moves between the photos of a bracket (a night bracket on a tripod) no longer
+ leaves a black hole where the middle photo had it clipped. With Deghost, the brightest photo's copy of it in a
+ dark sky is now removed too.
+- Photo ▸ Photo Merge ▸ HDR for Each Bracket Set merges every bracket among the selected photos with the last HDR
+ settings, one after the other: each stack, and photos taken less than a second apart at different exposures.
+ From the command line: `lightcraft-cli merge hdr-batch FOLDER`.
+- Merging uses about a quarter less memory: three 67 MP raws need 3.8 GB instead of 4.8 GB.
+
+### XMP sidecars catch up after a network share comes back
+- With automatic XMP writing on, an edit to a photo whose folder can't be written (a network share that dropped
+ out, a folder that went read-only) used to be written only to the library, with a line in the log, so the sidecar
+ stayed behind the edit. LightCraft now says once that the sidecars are waiting, tries again every few seconds once
+ the files are reachable, and says when they're written. `library.retrySidecars` does it on request.
+
+### Reliability
+- A damaged or crafted raw can no longer make LightCraft set aside gigabytes of memory before finding out the file is
+ bad (issue #1512): a compressed PEF whose data is too short for the size it declares, an uncompressed TIFF-based
+ raw whose tile claims far more samples than it holds, and an ARW6 with a broken tile are refused first. All 74
+ files in the test corpus still decode.
+
+### Reliability
+- Thumbnails and previews are written to the cache on disk by one background writer instead of a new thread for
+ each image (issue #1522). When renders come in faster than the disk takes them, at most 128 MB of images wait;
+ past that a write is skipped (the image stays in memory and is written by a later render), so a slow disk can't
+ pile up threads and memory.
+
+### Reliability
+- Saving the catalog and resuming a model download no longer write through a link left at the temporary file's
+ name (`catalog.snap.tmp`, `model.onnx.part`): the link is removed and a new file made in its place, so the file it
+ pointed to is never changed (issue #1502).
+
+### Reliability
+- A photo whose file was replaced (Reload Changed Files after an outside edit) no longer keeps the faces recognition
+ made from the old pixels: they are made again from the new file, and a scan still busy with the old file when it
+ changed doesn't put its faces on the new one (issue #1524).
+
+### Settings stays put when you change tabs
+- The Settings window keeps its top edge and width when you switch tabs, so the tab row no longer jumps around
+ under the pointer. It used to be centred, so every tab of a different height moved it.
+
+### Layout image over the loupe
+- View ▸ Loupe Overlay ▸ Choose Layout Image… draws a PNG with transparency over the photo in the loupe, such as
+ a magazine cover's masthead and cover lines, so you can frame a shot for the page it is made for. It fits inside
+ the photo, follows zoom and pan, and ⌥⌘O shows or hides it. The same menu sets its opacity and a matte that
+ darkens the photo outside it. The layout stays chosen across launches.
+
+### Smaller JPEG exports
+- JPEG exports are 12–14 % smaller at the same quality, with exactly the same pixels (issue #1373): each file now
+ carries Huffman tables made for its own picture instead of the standard example tables. Every viewer opens them
+ as before.
+
+### Reliability
+- A photo whose Defringe amount was stored far past the sliders' 20 (in a damaged catalog or sidecar) no longer
+ crashes LightCraft each time it renders: the amount acts as 20.
+
+ ### Lens names for Nikon DSLR raws
+ - Photos from Nikon DSLRs like the D700, D750, D80 or D5300 now show which lens they were taken with, for example
+ "24.0-70.0 mm f/2.8". Those cameras don't write a lens name, so the lens field was empty and you couldn't filter or
+ search by lens. LightCraft now reads the lens range Nikon keeps in its own maker note, the way Lightroom shows a
+ lens it doesn't have a name for. Newly imported photos show it.
+
### Hard-edged Heal and Clone spots
- A spot with Feather at 0 no longer draws black pixels exactly on its radius. This also fixes spots at 0% Opacity
changing pixels along their edge. The hard edge now leaves pixels on the radius unchanged.