From ea7777107dabc943697949d5fdbfb2fc143000a7 Mon Sep 17 00:00:00 2001 From: radialmonster Date: Sat, 10 Oct 2026 06:06:18 -0400 Subject: [PATCH] LR-IMP-FORMATS: decode Kodak DCS520C raw TIFF (two-component lossless JPEG with response curve) --- crates/engine/src/media.rs | 2 +- crates/raw/src/lib.rs | 7 + crates/raw/src/vendor/kodak.rs | 283 +++++++++++++++++++++++++++++++++ crates/raw/src/vendor/mod.rs | 1 + crates/raw/tests/corpus.rs | 44 +++++ docs/parity.md | 2 +- 6 files changed, 337 insertions(+), 2 deletions(-) create mode 100644 crates/raw/src/vendor/kodak.rs diff --git a/crates/engine/src/media.rs b/crates/engine/src/media.rs index 6d5b548f1..b3cde6abc 100644 --- a/crates/engine/src/media.rs +++ b/crates/engine/src/media.rs @@ -62,7 +62,7 @@ impl SettingsHashes { } /// Bump when the pipeline's output changes, to invalidate cached thumbnails. -pub const RENDER_CACHE_VERSION: u64 = 42; +pub const RENDER_CACHE_VERSION: u64 = 47; /// Thumbnails render at one of these long edges (so window/cell size changes reuse the cache). pub const THUMB_SIZES: [usize; 4] = [128, 256, 384, 512]; diff --git a/crates/raw/src/lib.rs b/crates/raw/src/lib.rs index f0331d610..e8fb78610 100644 --- a/crates/raw/src/lib.rs +++ b/crates/raw/src/lib.rs @@ -103,6 +103,8 @@ pub enum RawFormat { /// full-resolution CFA image with black/white levels, a default crop and `AsShotNeutral`): /// Hasselblad 3FR and FFF. Read by the DNG reader. CfaTiff, + /// Kodak DCS520C TIFF: a two-component lossless JPEG CFA sub-IFD with a response curve (`vendor::kodak`). + KodakDcs, /// Another TIFF-based raw (3FR, IIQ, ERF, KDC, DCR, MOS, …). OtherTiff, } @@ -123,6 +125,7 @@ impl RawFormat { | RawFormat::Pef | RawFormat::CfaTiff | RawFormat::Srw + | RawFormat::KodakDcs ) } } @@ -186,6 +189,9 @@ pub fn probe(bytes: &[u8]) -> Option { if make.starts_with("SAMSUNG") && samsung_raw { return Some(RawFormat::Srw); } + if vendor::kodak::raw_ifd(&t, bytes).is_some() { + return Some(RawFormat::KodakDcs); + } if dng::is_plain_cfa_tiff(&t, bytes) { return Some(RawFormat::CfaTiff); } @@ -347,6 +353,7 @@ fn decode_with(bytes: &[u8], mode: Mode) -> Result { RawFormat::Orf => vendor::orf::decode(bytes, mode), RawFormat::CfaTiff => dng::decode_as(bytes, mode, RawFormat::CfaTiff).map(lift_clipped), RawFormat::Srw => vendor::srw::decode(bytes, mode), + RawFormat::KodakDcs => vendor::kodak::decode(bytes, mode), RawFormat::OtherTiff => Err(RawError::Unsupported(other_tiff_reason(bytes))), other => Err(RawError::Unsupported(format!("{other:?} files are not decoded yet"))), } diff --git a/crates/raw/src/vendor/kodak.rs b/crates/raw/src/vendor/kodak.rs new file mode 100644 index 000000000..f7f82cff8 --- /dev/null +++ b/crates/raw/src/vendor/kodak.rs @@ -0,0 +1,283 @@ +//! Kodak DCS520C raw TIFF: the CFA sub-IFD holds one lossless JPEG (SOF3) stream of two components. +//! +//! Sources: TIFF 6.0 (container; `GrayResponseCurve` `0x123`; the CFA tags `CFARepeatPatternDim` and `CFAPattern`), +//! ITU T.81 (lossless JPEG, process SOF3), LightCraft's own decoder in [`crate::ljpeg`], the file's `KodakIFD` +//! (`0x8290`, a plain IFD with absolute offsets) and our own black-box analysis of the one CC0 sample from +//! raw.pixls.us (2573, DCS520C; every number below was measured on it): +//! +//! - The raw IFD is `Compression` 7, photometric 32803 (CFA), 12 bits, one strip, `ImageWidth` x `ImageLength` = +//! 1736 x 1160. Its stream is a 12-bit lossless JPEG of 868 x 1160 with two components; the decoder's interleaved +//! output (component 0, component 1, per pixel) is the mosaic row by row, so component 0 is the even columns and +//! component 1 the odd ones. The stream ends exactly at the strip's end. Recognised structurally: a Kodak make +//! and a stream whose width times its component count is the IFD's `ImageWidth`. +//! - `CFAPattern` bytes `01 00 02 01` (anchored at the first sample) are GRBG; the decoded colours follow the IFD0 +//! RGB thumbnail (156 x 104) with that layout. +//! - The samples span only 191..=622 because they are stored companded: IFD `GrayResponseCurve` (`0x123`, 4096 +//! entries) is a non-decreasing table that is the identity below 216 and expands the rest to 12-bit linear +//! values (623 distinct values, stored 622 gives 4095 and so does every higher code). Applying it makes the +//! frame linear with 12-bit white 4095. +//! - No masked border: all four edges are picture. Black differs per colour: the darkest 0.01% of each CFA +//! position's samples sit at 220 (G), 223 (R) and 197 (B) after the table (scene shadows end at the sensor's +//! black), so black is measured per position from the samples. +//! - White balance: five rational triples in the `KodakIFD` look like neutral sensor values (`0x848`, `0x849`, +//! `0x84a`, `0x84c`, `0x84d`). Against the thumbnail's neutral pixels (370 pixels with R, G and B within 6 of +//! each other) the raw G/R is 0.94 and G/B 1.96; `0x848` (1913, 1834, 921) gives 0.96 and 1.99, the others +//! 0.77..1.25 and 2.08..2.96, so its green over red and over blue are the gains. +use crate::{BlackLevel, Cfa, ColorData, Mode, OpcodeLists, RawData, RawError, RawFormat, RawImage, Rect, Result, ljpeg}; +use lightcraft_geom::Orientation; +use lightcraft_tiff::image::chunk_bytes; +use lightcraft_tiff::{Ifd, Tiff, tags as t}; + +/// The vendor IFD pointer (`KodakIFD`). +const KODAK_IFD: u16 = 0x8290; +/// Rational triple (red, green, blue) of neutral sensor values, see the module notes. +const NEUTRAL: u16 = 0x848; +/// TIFF `GrayResponseCurve`. +const RESPONSE_CURVE: u16 = 0x123; +/// Entries of the response curve: one per 12-bit code. +const CURVE_LEN: usize = 4096; + +/// The raw sub-IFD of a Kodak DCS TIFF with this layout: the CFA image whose single lossless JPEG stream has two +/// components, `ImageWidth / 2` columns and `ImageLength` rows, 12 bits. +pub(crate) fn raw_ifd<'a>(tiff: &'a Tiff, bytes: &[u8]) -> Option<&'a Ifd> { + let make = tiff.find(t::MAKE).and_then(|e| e.value.as_str())?; + if !make.to_ascii_uppercase().starts_with("KODAK") { + return None; + } + tiff.all_ifds().into_iter().find(|i| { + if i.u16(t::PHOTOMETRIC) != Some(t::photometric::CFA) || i.u16(t::COMPRESSION) != Some(t::compression::JPEG) { + return false; + } + let Ok(info) = i.image() else { return false }; + let chunks = info.chunks(bytes.len() as u64); + let [chunk] = chunks.as_slice() else { return false }; + let Some(src) = chunk_bytes(bytes, chunk) else { return false }; + matches!( + ljpeg::frame_info(src), + Ok((w, h, 2, 12)) if w.checked_mul(2) == Some(info.width as usize) && h == info.height as usize + ) && i.u64s(RESPONSE_CURVE).is_some_and(|c| c.len() == CURVE_LEN) + }) +} + +pub(crate) fn decode(bytes: &[u8], mode: Mode) -> Result { + let tiff = Tiff::parse(bytes)?; + let ifd0 = tiff.ifds.first().ok_or_else(|| RawError::Corrupt("Kodak TIFF without IFDs".into()))?; + let raw = raw_ifd(&tiff, bytes).ok_or_else(|| RawError::Unsupported("Kodak raw image not found".into()))?; + let info = raw.image()?; + let (w, h) = (info.width as usize, info.height as usize); + let n = w.checked_mul(h).filter(|n| *n > 0 && *n <= crate::MAX_SAMPLES).ok_or(RawError::Limit("image too large"))?; + let cfa = match (raw.u64s(t::CFA_REPEAT_PATTERN_DIM).as_deref(), raw.bytes(t::CFA_PATTERN_EP)) { + (Some([2, 2]), Some(p)) if p.len() == 4 && p.iter().all(|&c| c <= 2) => Cfa { width: 2, height: 2, pattern: p.to_vec() }, + _ => return Err(RawError::Unsupported("Kodak raw without a 2x2 CFAPattern".into())), + }; + let curve: Vec = raw + .u64s(RESPONSE_CURVE) + .filter(|c| c.len() == CURVE_LEN && c.windows(2).all(|p| p[0] <= p[1]) && c.iter().all(|&v| v < CURVE_LEN as u64)) + .ok_or_else(|| RawError::Unsupported("Kodak raw without a usable response curve".into()))? + .into_iter() + .map(|v| v as u16) + .collect(); + let (black, data) = if mode == Mode::Full { + let chunks = info.chunks(bytes.len() as u64); + let src = chunks.first().and_then(|c| chunk_bytes(bytes, c)).ok_or_else(|| RawError::Corrupt("Kodak strip outside file".into()))?; + let f = ljpeg::decode(src, n)?; + if f.components != 2 || f.width * 2 != w || f.height != h || f.data.len() != n { + return Err(RawError::Corrupt("Kodak lossless JPEG does not match the image size".into())); + } + let mut d = f.data; + for v in &mut d { + *v = curve.get(usize::from(*v)).copied().unwrap_or(CURVE_LEN as u16 - 1); + } + (measured_black(&d, w), RawData::U16(d)) + } else { + (BlackLevel::uniform(0.0), RawData::U16(Vec::new())) + }; + let wb = kodak_ifd(bytes, &tiff, ifd0) + .and_then(|k| k.f64s(NEUTRAL)) + .filter(|v| v.len() == 3 && v.iter().all(|&x| x > 0.0)) + .map(|v| [(v[1] / v[0]) as f32, 1.0, (v[1] / v[2]) as f32]); + let mut metadata = lightcraft_meta::from_tiff(&tiff); + metadata.width = Some(w as u32); + metadata.height = Some(h as u32); + let img = RawImage { + format: RawFormat::KodakDcs, + width: w, + height: h, + cpp: 1, + data, + cfa: Some(cfa), + bits: 12, + black, + white: vec![(CURVE_LEN - 1) as f32], + active_area: Rect::new(0, 0, w, h), + crop: Rect::new(0, 0, w, h), + orientation: Orientation::from_exif(ifd0.u16(t::ORIENTATION).unwrap_or(1)), + color: ColorData::default(), + wb_multipliers: wb, + linearized: false, + opcodes: OpcodeLists::default(), + metadata, + }; + img.validate_for(mode)?; + Ok(img) +} + +/// The vendor IFD (`KodakIFD`): a plain IFD with absolute value offsets. +fn kodak_ifd(bytes: &[u8], tiff: &Tiff, ifd0: &Ifd) -> Option { + let off = u64::from(ifd0.u32(KODAK_IFD)?); + let opts = lightcraft_tiff::ParseOptions { max_ifds: 4, max_depth: 1, follow_children: false, ..Default::default() }; + lightcraft_tiff::parse_ifd_at(bytes, off, tiff.order, 0, false, &opts).ok().map(|(i, _)| i) +} + +/// Black level per CFA position (the mosaic's first sample is position 0): the value below which only 0.01% of that +/// position's samples fall, see the module notes. Uniform 0 for an empty frame. +fn measured_black(d: &[u16], w: usize) -> BlackLevel { + let mut hist = vec![[0u32; CURVE_LEN]; 4]; + let mut count = [0u64; 4]; + for (y, row) in d.chunks(w.max(1)).enumerate() { + for (x, &v) in row.iter().enumerate() { + let p = (y & 1) * 2 + (x & 1); + hist[p][usize::from(v).min(CURVE_LEN - 1)] += 1; + count[p] += 1; + } + } + if count.contains(&0) { + return BlackLevel::uniform(0.0); + } + let values = (0..4) + .map(|p| { + let limit = count[p].div_ceil(10_000); + let mut seen = 0u64; + let level = hist[p] + .iter() + .position(|&c| { + seen += u64::from(c); + seen >= limit + }) + .unwrap_or(0); + level as f32 + }) + .collect(); + BlackLevel { repeat_rows: 2, repeat_cols: 2, values, ..Default::default() } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{decode, probe, probe_info}; + use lightcraft_tiff::{ByteOrder, IfdBuilder, ImageData, TiffWriter, Value}; + + const W: usize = 16; + const H: usize = 8; + + /// A response curve: the identity below 100, then steeper, saturating at 4095. + fn curve() -> Vec { + (0..CURVE_LEN as u32).map(|i| if i < 100 { i as u16 } else { (100 + (i - 100) * 7).min(4095) as u16 }).collect() + } + + /// Stored mosaic: values 60..=300, in the range the curve expands. + fn stored() -> Vec { + (0..W * H).map(|i| 60 + ((i * 37) % 241) as u16).collect() + } + + /// A big-endian IFD of `(tag, SRATIONAL triple)` entries at `at` in the file. + fn kodak_ifd_bytes(at: usize, tag: u16, v: [i32; 3]) -> Vec { + let mut b = vec![0, 1]; + b.extend(tag.to_be_bytes()); + b.extend(10u16.to_be_bytes()); + b.extend(3u32.to_be_bytes()); + b.extend(((at + 2 + 12 + 4) as u32).to_be_bytes()); + b.extend([0; 4]); + for x in v { + b.extend(x.to_be_bytes()); + b.extend(1i32.to_be_bytes()); + } + b + } + + fn file(make: &str, stream: Vec, width: u32, with_curve: bool, wb: Option<[i32; 3]>) -> Vec { + let mut raw = IfdBuilder::new(); + raw.set(t::NEW_SUBFILE_TYPE, Value::Long(vec![0])); + raw.set(t::IMAGE_WIDTH, Value::Short(vec![width as u16])); + raw.set(t::IMAGE_LENGTH, Value::Short(vec![H as u16])); + raw.set(t::BITS_PER_SAMPLE, Value::Short(vec![12])); + raw.set(t::COMPRESSION, Value::Short(vec![7])); + raw.set(t::PHOTOMETRIC, Value::Short(vec![32803])); + raw.set(t::SAMPLES_PER_PIXEL, Value::Short(vec![1])); + if with_curve { + raw.set(RESPONSE_CURVE, Value::Short(curve())); + } + raw.set(t::CFA_REPEAT_PATTERN_DIM, Value::Short(vec![2, 2])); + raw.set(t::CFA_PATTERN_EP, Value::Byte(vec![1, 0, 2, 1])); + raw.set_image(ImageData::Strips { rows_per_strip: H as u32, strips: vec![stream] }); + let build = |ptr: u32| { + let mut ifd0 = IfdBuilder::new(); + ifd0.set(t::MAKE, Value::Ascii(make.into())); + ifd0.set(t::MODEL, Value::Ascii("DCS520C".into())); + if wb.is_some() { + ifd0.set(KODAK_IFD, Value::Long(vec![ptr])); + } + ifd0.add_sub_ifd(raw.clone()); + TiffWriter::new(ByteOrder::Big, false).write(&[ifd0]).unwrap() + }; + let mut bytes = build(0); + if let Some(v) = wb { + let at = bytes.len().next_multiple_of(2); + bytes = build(at as u32); + bytes.resize(at, 0); + bytes.extend(kodak_ifd_bytes(at, NEUTRAL, v)); + } + bytes + } + + fn stream() -> Vec { + ljpeg::encode(&stored(), W / 2, H, 2, 12, 1, 0) + } + + /// Known answer: two interleaved components are the even and odd columns, the response curve linearises them, + /// the layout is GRBG, white balance comes from the vendor IFD, black is measured per CFA position. + #[test] + fn two_component_stream_decodes_through_the_response_curve() { + let bytes = file("Kodak", stream(), W as u32, true, Some([1900, 1800, 900])); + assert_eq!(probe(&bytes), Some(RawFormat::KodakDcs)); + let r = decode(&bytes).unwrap(); + assert_eq!((r.format, r.width, r.height, r.bits), (RawFormat::KodakDcs, W, H, 12)); + let want: Vec = stored().iter().map(|&v| curve()[usize::from(v)]).collect(); + assert_eq!(r.data, RawData::U16(want.clone())); + assert_eq!(r.cfa.as_ref().unwrap().name(), "GRBG"); + assert_eq!(r.white, vec![4095.0]); + assert_eq!(r.wb_multipliers, Some([1800.0 / 1900.0, 1.0, 2.0])); + // 0.01% of 32 samples is the smallest one of each position + let w = &want; + let min = |y0: usize, x0: usize| (y0..H).step_by(2).flat_map(|y| (x0..W).step_by(2).map(move |x| w[y * W + x])).min().unwrap() as f32; + assert_eq!(r.black.values, vec![min(0, 0), min(0, 1), min(1, 0), min(1, 1)]); + let i = probe_info(&bytes).unwrap(); + assert_eq!((i.format, i.width, i.height, i.wb_multipliers), (RawFormat::KodakDcs, W, H, r.wb_multipliers)); + } + + /// Without the vendor IFD there is no white balance; the layout is recognised from the structure alone, so + /// another make, one component, a stream of another width or a missing curve change nothing for other files. + #[test] + fn only_this_layout_is_claimed() { + assert_eq!(decode(&file("Kodak", stream(), W as u32, true, None)).unwrap().wb_multipliers, None); + assert_ne!(probe(&file("Canon", stream(), W as u32, true, None)), Some(RawFormat::KodakDcs)); + assert_ne!(probe(&file("Kodak", stream(), W as u32 + 2, true, None)), Some(RawFormat::KodakDcs)); + assert_ne!(probe(&file("Kodak", stream(), W as u32, false, None)), Some(RawFormat::KodakDcs)); + let one = ljpeg::encode(&stored()[..W * H / 2], W, H / 2, 1, 12, 1, 0); + assert_ne!(probe(&file("Kodak", one, W as u32, true, None)), Some(RawFormat::KodakDcs)); + } + + /// Hostile input: truncated streams and tables report errors instead of panicking. + #[test] + fn damaged_files_are_errors() { + let s = stream(); + for cut in [s.len() / 2, 40, 0] { + let bytes = file("Kodak", s[..cut].to_vec(), W as u32, true, Some([1, 1, 1])); + if probe(&bytes) == Some(RawFormat::KodakDcs) { + assert!(decode(&bytes).is_err() || cut == s.len()); + } + } + let bytes = file("Kodak", s, W as u32, true, Some([0, 5, 0])); + assert_eq!(decode(&bytes).unwrap().wb_multipliers, None); + } +} diff --git a/crates/raw/src/vendor/mod.rs b/crates/raw/src/vendor/mod.rs index fcab4eabf..98bd180a7 100644 --- a/crates/raw/src/vendor/mod.rs +++ b/crates/raw/src/vendor/mod.rs @@ -6,6 +6,7 @@ pub mod cr2; pub mod cr3; pub mod crx; pub(crate) mod crx_wavelet; +pub mod kodak; pub mod nef; pub mod nefc; pub mod orf; diff --git a/crates/raw/tests/corpus.rs b/crates/raw/tests/corpus.rs index 8649dd703..b695adf8d 100644 --- a/crates/raw/tests/corpus.rs +++ b/crates/raw/tests/corpus.rs @@ -931,3 +931,47 @@ fn sony_embedded_distortion_is_limited_to_validated_models() { } eprintln!("Sony distortion model boundary: {checked} corpus files checked"); } + +/// Kodak DCS520C (`crates/raw/src/vendor/kodak.rs`): the two-component lossless JPEG strip decodes through the +/// file's response curve to a 1736 x 1160 GRBG mosaic with 12-bit white, per-position black levels and the +/// white balance of the vendor IFD. Looks for the corpus copy, then the raw.pixls.us folder; skips without either. +#[test] +fn corpus_kodak_dcs520c() { + let name = "2573_Kodak - DCS520C - 12bit (3_2).TIF"; + let candidates = [corpus_root().join("raw").join("kodak-dcs520c.tif"), Path::new("P:/raw-pixls/Kodak/DCS520C").join(name)]; + let Some(bytes) = candidates.iter().find_map(|p| std::fs::read(p).ok()) else { + eprintln!("skip: DCS520C sample absent"); + return; + }; + assert_eq!(probe(&bytes), Some(RawFormat::KodakDcs)); + let img = decode(&bytes).unwrap_or_else(|e| panic!("{e}")); + assert_eq!((img.width, img.height, img.bits), (1736, 1160, 12)); + assert_eq!(img.cfa.as_ref().map(|c| c.name()).as_deref(), Some("GRBG")); + assert_eq!(img.white_at(0), 4095.0); + let lightcraft_raw::RawData::U16(d) = &img.data else { panic!("float data") }; + assert_eq!(d.len(), 1736 * 1160); + // stored 191..=622 expands to 191..=4095 + assert_eq!((d.iter().min().copied(), d.iter().max().copied()), (Some(191), Some(4095))); + // black: G and R about 220, B about 197 (the darkest 0.01% of each position) + let b = &img.black.values; + assert_eq!(b.len(), 4); + assert!( + (200.0..=235.0).contains(&b[0]) && (200.0..=235.0).contains(&b[1]) && (185.0..=210.0).contains(&b[2]) && (200.0..=235.0).contains(&b[3]), + "{b:?}" + ); + let wb = img.wb_multipliers.expect("white balance"); + assert!((wb[0] - 0.9587).abs() < 1e-3 && wb[1] == 1.0 && (wb[2] - 1.9913).abs() < 1e-3, "{wb:?}"); + // no column stripes: the two greens sit in different JPEG components (G1 on even columns, G2 on odd columns), so a component mismatch would split them + let mean = |y0: usize, x0: usize| { + let (mut s, mut n) = (0f64, 0f64); + for y in (y0..1160).step_by(2) { + for x in (x0..1736).step_by(2) { + s += f64::from(d[y * 1736 + x]); + n += 1.0; + } + } + s / n + }; + let (g1, g2) = (mean(0, 0), mean(1, 1)); + assert!((g1 - g2).abs() < 0.01 * g1, "greens {g1} vs {g2}"); +} diff --git a/docs/parity.md b/docs/parity.md index d0bdc35c2..a3dfbea34 100644 --- a/docs/parity.md +++ b/docs/parity.md @@ -146,7 +146,7 @@ under the UI command that wraps it (a no-op error); the UI command now wins. | LR-IMP-PROFILES | Import profiles & presets | P1 | ✅ | `cmd:file.importPresets`, `cmd:preset.import`, `cmd:profile.import`, `crates/engine/src/preset_import.rs`, `crates/engine/src/preset_luminar.rs` | presets: .lcpreset, XMP, classic .lrtemplate, photos carrying edits ("DNG presets"), Luminar looks (.lmp, .mplumpack collections; sliders with a counterpart), .zip bundles, folders (folder → group), drag & drop; masks carried over; unmapped settings reported (fields that only describe the preset or photo, e.g. `Cluster`, `SortName`, `SupportsAmount2`, the as-shot white, empty Point Color slots, are not); profiles: .cube 3D LUTs; Adobe profile formats deliberately unsupported | | LR-IMP-LOCAL | Work on files in place | P0 | ✅ | `cmd:library.browse`, `cmd:photo.addToLibrary`, `cmd:library.import` (mode add), `cmd:local.addRoot`, `cmd:local.hide`, `cmd:local.restoreHidden`, `crates/engine/src/cmd/browse.rs`, `crates/ui-egui/src/panels/left.rs` (`local_section`), `crates/ui-egui/src/panels/grid.rs` (`folder_header`) | Local: browse Pictures / Desktop / Downloads / Home or any folder without adding it (breadcrumb, Include subfolders, Add N to My Photos); browsed photos stay out of All Photos, albums and counts; folders picked with Browse Folder… (or Keep in Local / Add to Local on a folder row) stay listed across restarts, and browsing a folder inside a listed one highlights it inside that tree (opened down to it, siblings reachable) instead of adding a root; edits go to XMP sidecars; importing promotes them; right-click a top-level location → Remove from Local hides the shortcut only (nothing on disk or in the catalog changes), saved with the UI state, and “Show N hidden locations” (or Browse Folder… on it) brings it back; a folder is one location however its path is spelled (`/` or `\`, trailing separator, `.`/`..`, drive-letter case; `folder_key` in `crates/catalog/src/query.rs`); browsed photos nobody changed are forgotten once their folder has not been browsed for 30 days (Settings → Performance → Local folders, 0 = never; checked when the library opens, or `cmd:library.forgetLocal` with `dryRun`; files and sidecars stay, browsing again brings them back; see `crates/catalog/src/local.rs` for what counts as a change) | | LR-IMP-SIDECAR-SPLIT | Separate XMP sidecar variants | P2 | ⬜ | `cmd:library.xmpPreferences` | sidecar naming option exists (stem/full), no split sidecars | -| LR-IMP-FORMATS | Supported formats | P0 | 🟡 | `crates/codecs/src/lib.rs`, `crates/raw/src/lib.rs`, `crates/raw/src/jxl.rs` | JPEG, PNG, TIFF (1- to 64-bit integer, 16- to 64-bit float, incl. bilevel and CCITT fax), WebP, JXL, PSD, GIF, BMP; DNG (incl. lossy / Smart Preview DNG and DNG 1.7 JPEG XL tiles/strips: lossless ones decode bit-exactly on synthetic CFA and LinearRaw files, lossy ones are restored to the declared linear primaries without clipping or gamut mapping, checked on one real file with 108 lossy tiles, and any tile that fails to decode makes the file preview-only; DNG 1.7 row/column-interleaved rasters (`RowInterleaveFactor` / `ColumnInterleaveFactor`) are undone before the mosaic is read, so a file from Adobe's converter with a 2×2 interleave no longer decodes as four scaled-down copies in the wrong colours; a dimension the factor does not divide decodes with short trailing fields; verified on 4 real ILCE-6400 JPEG XL DNGs rendering bit-identical to their non-interleaved twins, factors above 2 rest on the plain reading of the tag; a single-chunk JPEG XL preview IFD is offered as the embedded preview; a DNG whose samples pile up at one value well below its stated `WhiteLevel`, as a camera app's 12-bit Bayer DNG that states 4095 and clips at 3567, has those samples raised to the white level on decode, so highlight reconstruction sees the clipped areas instead of white balance tinting them magenta, issue #548, `crates/raw/src/saturation.rs`), CR2 (colour-filter layout from the file's `CR2CFAPattern` tag, issue #85), ARW (pre-2017 bodies: white balance and black level from the encrypted `SR2SubIFD`, issue #148, its `WB_RGGBLevels` being the white balance the camera applied, issue #535; the DSLR-A900's packed 12-bit strip, two pixels per three bytes, read only when the strip is exactly 1.5 bytes per pixel, with its camera-JPEG window centred, checked on one CC0 file (A850 unmeasured); downsized Sony lossless YCbCr 4:2:0 / 4:2:2 tiles decoded to linear RGB, verified on private ILCE-7M4 3:2 & 4:3 examples including 16-bit full-resolution export; Sony DSC-R1 .SR2 decodes, its big-endian 16-bit words read in the order that fits the sample range, checked on the CC0 3221 sample; its crop and white balance live in the SR2SubIFD and are not read yet), NEF (uncompressed, lossless and lossy compressed 12/14-bit, `crates/raw/src/vendor/nefc.rs`), RAF (uncompressed, lossless/lossy compressed Bayer and X-Trans; `crates/raw/src/vendor/rafc.rs`, full sensor verification on 13 bodies, `docs/raf-compression.md`), RW2 / Leica RWL / Panasonic RAW in every raw format (compressed 4 and 6, the prefix-coded strips of format 8 from the GH6 on, packed 2/5/7, the 16-bit words of the 2005–2007 bodies; black levels, in-camera aspect crops and mapped-out defect pixels; 178 CC0 files from 118 bodies checked, `crates/raw/src/vendor/rw2.rs`), PEF, ORF (uncompressed; colour-filter layout from the file's Exif `CFAPattern`; 12.8 bit/px 16-byte blocks of ten 12-bit samples + a zero pad byte, E-300 / E-330 / E-500 verified on CC0 files, E-M5 Mark II / PEN-F high-res files decode smooth but CFA and black unverified), Hasselblad 3FR and FFF (a TIFF without a DNG version tag that describes its CFA IFD, levels, crop and white balance with DNG's tags; `RawFormat::CfaTiff`, read by `dng::decode_as`, RGGB when the file states no `CFAPattern`): uncompressed (X1D, X1D II, X2D, CFV 100C) and Hasselblad's lossless JPEG with scan selection value 8 (every FFF; H3D, H4D and CFV-50c 3FR), `ljpeg::decode_hasselblad`, its rule measured on 14 CC0 files with the ljpeg-explorer tool, Samsung SRW without compression (NX5, NX10, NX11 and the NX20-generation bodies NX20, NX200, NX210, NX1000 and NX1100 as 12-bit packed samples in either bit order, EX1 and WB2000 as 16-bit words; layout, camera-JPEG framing, levels and white balance from the maker note, `crates/raw/src/vendor/srw.rs`; median ΔE vs the camera JPEG 2.2–7.6 on 11 of the 12 files from 10 bodies checked, 10.7 (5.7 registered) on the backlit WB2000 sample). 12-bit NEF black level: maker note `0x003d` is in 14-bit units (D750, D780, D850, D7500, Z 50 checked). Lossy type 2 NEF curves of version `0x44 0x40` (D780, D6, Z 5, Z 6, Z 7, Z 7_2) span a quarter of the sample range, read from the table's own point spacing. CR3 lossless CRX Bayer and version 0x100/0x200 C-RAW decodes to sensor pixels with timed white balance, black/white levels and file crop (the shot's aspect ratio from the maker note's `AspectInfo`); full sensor samples match the reference on M50/R100/R8 (`crates/raw/tests/cr3_corpus.rs`, `docs/cr3.md`). Unsupported coding variants retain metadata and use the embedded JPEG when available; HEVC preview decoding remains unsupported. Missing: CR3 unverified CRX variants, compressed ORF, compressed Samsung SRW (NX1, NX30, NX300, NX500, NX2000, NX3000, NX3300, NX mini: preview only with the reason), NEFs labelled compressed (34713) but stored uncompressed without a `0x0096` table (Z 6 packed 14-bit, D850 12-bit uncompressed), Nikon High Efficiency NEF (HE / HE★ from the Z 8, Z 9, Z 6III and Z f: compression 34713 with a JPEG XS codestream and no `0x0096` table; no public specification, so preview only with the reason "Nikon High Efficiency NEF", issue #193; Lossless compressed NEFs from the same bodies decode), NEF "lossy after split" (preview only: imported with `preview_only` = the decoder's reason, rendered as a rendered JPEG, flagged by a grid badge and loupe/Edit/Info notices, `previewOnly` in `catalog.query`; Reload clears it once the file decodes), TIFF-based raws whose raw data sits in a private block (Phase One / Leaf IIQ, Canon EOS-1D / 1Ds and Kodak DCS TIFFs: IFD0 is only a reduced RGB image next to a much larger declared picture) are recognised from that structure and import as `preview_only` with the reason, instead of opening as a thumbnail-sized ordinary image (`thumbnail_shell` in `crates/raw/src/lib.rs`), Recognised raws LightCraft cannot decode open as `preview_only` with any usable embedded JPEG, also Canon CRW, Minolta MRW and Sigma X3F (containers recognised by magic, preview found by a structural JPEG scan), Kodak KDC (IFD0 without `ImageWidth`), Leaf MOS and Epson ERF (scan), and any decode failure of a recognised raw, not only an unsupported variant; ones with no JPEG still fail with "without an embedded preview", AVIF decode (HEIC decodes only behind the non-default `heif` feature, which the release packages enable: `crates/heif`, heic-rs for the container and HEVC (bit-exact against libde265 on iPhone tiles) plus our own colour conversion, matching libheif within 1 code value on iPhone-style grids (VUI full range, Display P3 ICC, nclx, 10-bit, irot/imir/clap, gain map/depth ignored); 4:2:0/monochrome only, 4:2:2/4:4:4 Canon/Sony HIF refused; same policy as PhotoCraft), palette (indexed-colour) TIFF (refused by the `tiff` crate) | +| LR-IMP-FORMATS | Supported formats | P0 | 🟡 | `crates/codecs/src/lib.rs`, `crates/raw/src/lib.rs`, `crates/raw/src/jxl.rs` | JPEG, PNG, TIFF (1- to 64-bit integer, 16- to 64-bit float, incl. bilevel and CCITT fax), WebP, JXL, PSD, GIF, BMP; DNG (incl. lossy / Smart Preview DNG and DNG 1.7 JPEG XL tiles/strips: lossless ones decode bit-exactly on synthetic CFA and LinearRaw files, lossy ones are restored to the declared linear primaries without clipping or gamut mapping, checked on one real file with 108 lossy tiles, and any tile that fails to decode makes the file preview-only; DNG 1.7 row/column-interleaved rasters (`RowInterleaveFactor` / `ColumnInterleaveFactor`) are undone before the mosaic is read, so a file from Adobe's converter with a 2×2 interleave no longer decodes as four scaled-down copies in the wrong colours; a dimension the factor does not divide decodes with short trailing fields; verified on 4 real ILCE-6400 JPEG XL DNGs rendering bit-identical to their non-interleaved twins, factors above 2 rest on the plain reading of the tag; a single-chunk JPEG XL preview IFD is offered as the embedded preview; a DNG whose samples pile up at one value well below its stated `WhiteLevel`, as a camera app's 12-bit Bayer DNG that states 4095 and clips at 3567, has those samples raised to the white level on decode, so highlight reconstruction sees the clipped areas instead of white balance tinting them magenta, issue #548, `crates/raw/src/saturation.rs`), CR2 (colour-filter layout from the file's `CR2CFAPattern` tag, issue #85), ARW (pre-2017 bodies: white balance and black level from the encrypted `SR2SubIFD`, issue #148, its `WB_RGGBLevels` being the white balance the camera applied, issue #535; the DSLR-A900's packed 12-bit strip, two pixels per three bytes, read only when the strip is exactly 1.5 bytes per pixel, with its camera-JPEG window centred, checked on one CC0 file (A850 unmeasured); downsized Sony lossless YCbCr 4:2:0 / 4:2:2 tiles decoded to linear RGB, verified on private ILCE-7M4 3:2 & 4:3 examples including 16-bit full-resolution export; Sony DSC-R1 .SR2 decodes, its big-endian 16-bit words read in the order that fits the sample range, checked on the CC0 3221 sample; its crop and white balance live in the SR2SubIFD and are not read yet), NEF (uncompressed, lossless and lossy compressed 12/14-bit, `crates/raw/src/vendor/nefc.rs`), RAF (uncompressed, lossless/lossy compressed Bayer and X-Trans; `crates/raw/src/vendor/rafc.rs`, full sensor verification on 13 bodies, `docs/raf-compression.md`), RW2 / Leica RWL / Panasonic RAW in every raw format (compressed 4 and 6, the prefix-coded strips of format 8 from the GH6 on, packed 2/5/7, the 16-bit words of the 2005–2007 bodies; black levels, in-camera aspect crops and mapped-out defect pixels; 178 CC0 files from 118 bodies checked, `crates/raw/src/vendor/rw2.rs`), PEF, ORF (uncompressed; colour-filter layout from the file's Exif `CFAPattern`; 12.8 bit/px 16-byte blocks of ten 12-bit samples + a zero pad byte, E-300 / E-330 / E-500 verified on CC0 files, E-M5 Mark II / PEN-F high-res files decode smooth but CFA and black unverified), Kodak DCS520C TIFF (a two-component 12-bit lossless JPEG strip, the two components the even and odd columns; the file's `GrayResponseCurve` table linearises the companded samples to 12 bits, black measured per CFA position, white balance from the `KodakIFD`; `RawFormat::KodakDcs`, `crates/raw/src/vendor/kodak.rs`, checked on the one CC0 sample against its IFD0 thumbnail), Hasselblad 3FR and FFF (a TIFF without a DNG version tag that describes its CFA IFD, levels, crop and white balance with DNG's tags; `RawFormat::CfaTiff`, read by `dng::decode_as`, RGGB when the file states no `CFAPattern`): uncompressed (X1D, X1D II, X2D, CFV 100C) and Hasselblad's lossless JPEG with scan selection value 8 (every FFF; H3D, H4D and CFV-50c 3FR), `ljpeg::decode_hasselblad`, its rule measured on 14 CC0 files with the ljpeg-explorer tool, Samsung SRW without compression (NX5, NX10, NX11 and the NX20-generation bodies NX20, NX200, NX210, NX1000 and NX1100 as 12-bit packed samples in either bit order, EX1 and WB2000 as 16-bit words; layout, camera-JPEG framing, levels and white balance from the maker note, `crates/raw/src/vendor/srw.rs`; median ΔE vs the camera JPEG 2.2–7.6 on 11 of the 12 files from 10 bodies checked, 10.7 (5.7 registered) on the backlit WB2000 sample). 12-bit NEF black level: maker note `0x003d` is in 14-bit units (D750, D780, D850, D7500, Z 50 checked). Lossy type 2 NEF curves of version `0x44 0x40` (D780, D6, Z 5, Z 6, Z 7, Z 7_2) span a quarter of the sample range, read from the table's own point spacing. CR3 lossless CRX Bayer and version 0x100/0x200 C-RAW decodes to sensor pixels with timed white balance, black/white levels and file crop (the shot's aspect ratio from the maker note's `AspectInfo`); full sensor samples match the reference on M50/R100/R8 (`crates/raw/tests/cr3_corpus.rs`, `docs/cr3.md`). Unsupported coding variants retain metadata and use the embedded JPEG when available; HEVC preview decoding remains unsupported. Missing: CR3 unverified CRX variants, compressed ORF, compressed Samsung SRW (NX1, NX30, NX300, NX500, NX2000, NX3000, NX3300, NX mini: preview only with the reason), NEFs labelled compressed (34713) but stored uncompressed without a `0x0096` table (Z 6 packed 14-bit, D850 12-bit uncompressed), Nikon High Efficiency NEF (HE / HE★ from the Z 8, Z 9, Z 6III and Z f: compression 34713 with a JPEG XS codestream and no `0x0096` table; no public specification, so preview only with the reason "Nikon High Efficiency NEF", issue #193; Lossless compressed NEFs from the same bodies decode), NEF "lossy after split" (preview only: imported with `preview_only` = the decoder's reason, rendered as a rendered JPEG, flagged by a grid badge and loupe/Edit/Info notices, `previewOnly` in `catalog.query`; Reload clears it once the file decodes), TIFF-based raws whose raw data sits in a private block (Phase One / Leaf IIQ, Canon EOS-1D / 1Ds and the Kodak DCS Pro / DCS760C TIFFs (compression 65000): IFD0 is only a reduced RGB image next to a much larger declared picture) are recognised from that structure and import as `preview_only` with the reason, instead of opening as a thumbnail-sized ordinary image (`thumbnail_shell` in `crates/raw/src/lib.rs`), Recognised raws LightCraft cannot decode open as `preview_only` with any usable embedded JPEG, also Canon CRW, Minolta MRW and Sigma X3F (containers recognised by magic, preview found by a structural JPEG scan), Kodak KDC (IFD0 without `ImageWidth`), Leaf MOS and Epson ERF (scan), and any decode failure of a recognised raw, not only an unsupported variant; ones with no JPEG still fail with "without an embedded preview", AVIF decode (HEIC decodes only behind the non-default `heif` feature, which the release packages enable: `crates/heif`, heic-rs for the container and HEVC (bit-exact against libde265 on iPhone tiles) plus our own colour conversion, matching libheif within 1 code value on iPhone-style grids (VUI full range, Display P3 ICC, nclx, 10-bit, irot/imir/clap, gain map/depth ignored); 4:2:0/monochrome only, 4:2:2/4:4:4 Canon/Sony HIF refused; same policy as PhotoCraft), palette (indexed-colour) TIFF (refused by the `tiff` crate) | | LR-IMP-CAMERA-COVERAGE | Camera coverage, verified per model | P0 | 🟡 | `crates/raw/tests/corpus.rs`, `xtask/src/main.rs` | a supported container is not the same as every camera that writes it decoding correctly: ~55 CC0 corpus files plus 6 exact-sensor CR3 cases (plus ~60 NEFs checked by hand and 178 Panasonic / Leica RW2, RWL and RAW files from 118 bodies, checked against each file's own JPEG) against the >1,000 models Lightroom lists; per-model differences still surface (e.g. the CR2 colour-filter layout differed by model until it was read from the file's own tag, issue #85, checked on 35 CR2 bodies; CR2 black levels were read from border columns light already reaches, left of `SensorInfo`'s border, so CR2s rendered dark with crushed shadows (EOS 6D: 2591 instead of 2047), now measured from the masked columns only, checked on 8 corpus bodies; pre-2017 Sony ARWs opened green until their scrambled white balance / black level were read, issue #148, checked on 16 ARWs from 15 Sony bodies; their white balance now comes from the encrypted `SR2SubIFD`'s `WB_RGGBLevels`, the gains the camera applied, which 14 bodies (DSLR-A450 … A700, NEX-3/5/C3, SLT-A33/A35/A55, ILCE-6001, UMC-R10C) had no other source for and which the maker-note estimate read before missed by up to 100 % on preset shots, issue #535, checked against ExifTool on 100 decoded ARWs from 87 Sony bodies; the encrypted SR2 black level is now read from its directory entry (the DSLR-A450/A500/A550/A700 read 354–975 instead of 512), checked on 126 ARWs from 97 Sony bodies, and downsized lossless M/S ARWs use their measured black level 1024 instead of 512, checked on 12 files from 4 bodies, issue #535; pre-2017 Sony bodies shot in the camera's 16:9 mode (ILCE-7SM2, DSLR-A580) now get the 16:9 crop of their camera JPEG instead of the whole 3:2 frame with padding columns, issue #535; Canon PowerShot and EOS M CR2s whose `ColorData` is stored as bytes opened green until the bytes were read as 16-bit words, 25 files from 25 bodies checked). Compressed RAF sensor arrays verified on 13 Fujifilm bodies (`docs/raf-compression.md`). Sony ILCE-7CR (61 MP): lossless compressed L and M and compressed ARW2 samples of one scene in the corpus (black level, default crop, as-shot gains, lossless vs compressed mosaic agreement, fitted camera look), and all nine public codings (also uncompressed, small and APS-C crop) decode and fit. Grow the CC0 corpus per model and test each sample decodes with plausible colour. Nikon CropArea and untagged-preview colour-space regression tests; private Z 8 crop verified. | | LR-IMP-CULL-AT-IMPORT | Culling analysis at import | P2 | 🟡 | `cmd:photo.analyze` | run Assisted Culling on the imported photos (they're selected after an import); not automatic | | LR-IMP-MOVE | Move on import [Classic] | P1 | ✅ | `cmd:library.import` (`mode` move), `crates/engine/src/import_move.rs`, `crates/engine/src/tests_import_move.rs`, `crates/ui-egui/src/import.rs` | Transfer ▸ Move with Copy's destination, folders (day / month / one folder / custom template), rename template and example destination; XMP sidecars (both namings) move along; each source is removed only after its destination is written (hard link on the same volume, else copied, synced and compared byte for byte) and its catalog record is saved; failed, duplicate, unchecked files keep their sources, taken names get -1, -2…, never overwritten; files already in the destination/library are added in place; sources that can't be removed (read-only card) are kept and reported (`kept`). Undo removes the photos from the library but leaves the moved files at the destination. No Copy as DNG while moving |