Skip to content

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

LR-IMP-FORMATS: raws we cannot decode import as preview only when any usable JPEG is embedded

radialmonsterdbe73f0f9c18
diff --git a/crates/engine/src/files.rs b/crates/engine/src/files.rs
index 1686ebb83..900562492 100644
--- a/crates/engine/src/files.rs
+++ b/crates/engine/src/files.rs
@@ -182,11 +182,15 @@ pub fn probe_bytes(name: &str, bytes: &[u8]) -> Result<ProbeInfo, String> {
/// Why a raw that failed to decode should show its embedded preview instead (`Ok`), or the error
/// to report (`Err`). Variants we can't decode yet always fall back. So does any CR3 error: the CRX
/// decoder is verified on few bodies, and every CR3 opened from its embedded JPEG before it existed.
+/// So does any other failure of a recognised raw (damaged or oversized raw data, unreadable TIFF
+/// structure): its preview may still be intact. Only a file that is not a raw reports an error.
fn preview_reason(bytes: &[u8], e: lightcraft_raw::RawError) -> Result<String, String> {
+ use lightcraft_raw::RawError;
match e {
- lightcraft_raw::RawError::Unsupported(why) => Ok(why),
+ RawError::Unsupported(why) => Ok(why),
e if lightcraft_raw::probe(bytes) == Some(lightcraft_raw::RawFormat::Cr3) => Ok(format!("CR3 {e}")),
- e => Err(e.to_string()),
+ RawError::NotRaw => Err(RawError::NotRaw.to_string()),
+ e => Ok(e.to_string()),
}
}
@@ -761,6 +765,41 @@ mod tests {
assert!(lightcraft_raw::probe(&tiff_shell(24, 16, false)).is_none());
}
+ /// Recognised raw containers we don't decode (Minolta MRW here: the preview's first byte is
+ /// overwritten in the file) import as preview only with the JPEG's size, instead of failing.
+ #[test]
+ fn undecodable_container_with_a_preview_imports_as_preview_only() {
+ let px: Vec<u8> = (0..40 * 30).flat_map(|i| [(i % 251) as u8, 128, 200]).collect();
+ let mut jpeg = encode_jpeg(&EncodeImage::new(40, 30, 3, Samples::U8(&px)), 90, ChromaSubsampling::S444, &EncodeMeta::default()).unwrap();
+ jpeg[0] = 0x02;
+ let mut f = b"\0MRM\0\x01\0\0".to_vec();
+ f.extend(std::iter::repeat_n(0x11u8, 300));
+ f.extend_from_slice(&jpeg);
+ f.extend(std::iter::repeat_n(0x22u8, 300));
+ let p = probe_bytes("A.MRW", &f).unwrap();
+ assert_eq!((p.kind, p.format.as_str(), p.width, p.height), (MediaKind::Raw, "MRW", 40, 30));
+ assert!(p.preview_only.is_some_and(|w| w.contains("Mrw")));
+ let (img, src) = load_bytes(&f, 20).unwrap();
+ assert_eq!((img.width, img.height, src.raw), (20, 15, false));
+ // without a JPEG: a clear error
+ let e = probe_bytes("A.MRW", b"\0MRM\0\x01\0\0 nothing here").unwrap_err();
+ assert!(e.contains("without an embedded preview"), "{e}");
+ }
+
+ /// Any failure of a recognised raw (not only an unsupported variant) can fall back to its preview;
+ /// CR3 keeps its own wording.
+ #[test]
+ fn decode_failures_of_recognised_raws_may_fall_back_to_the_preview() {
+ use lightcraft_raw::RawError;
+ let cr3 = b"\0\0\0\x18ftypcrx \0\0\0\x01";
+ assert_eq!(preview_reason(b"x", RawError::Unsupported("x".into())), Ok("x".to_string()));
+ assert!(preview_reason(b"x", RawError::Corrupt("bad strip".into())).is_ok_and(|w| w.contains("bad strip")));
+ assert!(preview_reason(b"x", RawError::Limit("too big")).is_ok());
+ assert!(preview_reason(b"x", RawError::Tiff(lightcraft_tiff::TiffError::MissingTag(256))).is_ok());
+ assert!(preview_reason(b"x", RawError::NotRaw).is_err());
+ assert!(preview_reason(cr3, RawError::Corrupt("bad".into())).is_ok_and(|w| w.starts_with("CR3 ")));
+ }
+
#[test]
fn quick_jobs_show_embedded_previews_then_cached_renders() {
use crate::media::QuickSource;
diff --git a/crates/raw/src/lib.rs b/crates/raw/src/lib.rs
index 3bd59a3ed..d63e52544 100644
--- a/crates/raw/src/lib.rs
+++ b/crates/raw/src/lib.rs
@@ -83,6 +83,12 @@ pub enum RawFormat {
Rw2,
Pef,
Srw,
+ /// Canon CRW (CIFF heap), the bodies before the CR2 era.
+ Crw,
+ /// Minolta MRW (`\0MRM` block container).
+ Mrw,
+ /// Sigma / Foveon X3F (`FOVb`).
+ X3f,
/// Another TIFF-based raw (3FR, IIQ, ERF, KDC, DCR, MOS, …).
OtherTiff,
}
@@ -119,6 +125,15 @@ pub fn probe(bytes: &[u8]) -> Option<RawFormat> {
if bytes.starts_with(b"IIU\0") {
return Some(RawFormat::Rw2);
}
+ if bytes.starts_with(b"\0MRM") {
+ return Some(RawFormat::Mrw);
+ }
+ if bytes.starts_with(b"FOVb") {
+ return Some(RawFormat::X3f);
+ }
+ if bytes.len() >= 14 && bytes.starts_with(b"II") && &bytes[6..14] == b"HEAPCCDR" {
+ return Some(RawFormat::Crw);
+ }
if bytes.len() >= 10 && bytes.starts_with(b"II*\0") && &bytes[8..10] == b"CR" {
return Some(RawFormat::Cr2);
}
@@ -146,20 +161,29 @@ pub fn probe(bytes: &[u8]) -> Option<RawFormat> {
if make.starts_with("SAMSUNG") {
return Some(RawFormat::Srw);
}
- if has_cfa || thumbnail_shell(&t, bytes.len()).is_some() {
+ if has_cfa || thumbnail_shell(&t, bytes.len()).is_some() || is_preview_container(ifd0) {
return Some(RawFormat::OtherTiff);
}
None
}
-/// Whether some IFD is marked as raw: CFA photometric, or a raw-only compression value.
+/// Whether some IFD is marked as raw: CFA photometric, or a raw-only compression value (99 is not a
+/// registered TIFF compression; Leaf MOS files use it for their tiled 16-bit lossless-JPEG raw).
fn has_raw_ifd(t: &Tiff) -> bool {
t.all_ifds().iter().any(|i| {
i.u16(lightcraft_tiff::tags::PHOTOMETRIC) == Some(lightcraft_tiff::tags::photometric::CFA)
- || i.u16(lightcraft_tiff::tags::COMPRESSION).is_some_and(|c| c == 34713 || c == 32767 || c == 32769 || c == 32770)
+ || i.u16(lightcraft_tiff::tags::COMPRESSION).is_some_and(|c| c == 34713 || c == 32767 || c == 32769 || c == 32770 || c == 99)
})
}
+/// IFD0 that is not an image at all: no `ImageWidth` / `ImageLength`, but a JPEG preview pointer or
+/// `SubIFDs` (the layout of Kodak KDC files, whose pictures sit in private tags). A plain TIFF reader
+/// rejects such a file as malformed even though it carries a preview.
+fn is_preview_container(ifd0: &lightcraft_tiff::Ifd) -> bool {
+ use lightcraft_tiff::tags::{IMAGE_LENGTH, IMAGE_WIDTH, JPEG_INTERCHANGE_FORMAT, SUB_IFDS};
+ !ifd0.contains(IMAGE_WIDTH) && !ifd0.contains(IMAGE_LENGTH) && (ifd0.contains(JPEG_INTERCHANGE_FORMAT) || ifd0.contains(SUB_IFDS))
+}
+
/// A TIFF whose first image is only a reduced copy of a picture stored somewhere else.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) struct ThumbnailShell {
@@ -788,6 +812,51 @@ mod tests {
assert_eq!(probe(&padded(&[IfdBuilder::new().with(t::MAKE, Value::Ascii("X".into()))])), None);
}
+ // --- containers that are recognised but not decoded, with a preview ---
+
+ #[test]
+ fn private_containers_are_recognised_by_their_magic() {
+ assert_eq!(probe(b"II\x1a\0\0\0HEAPCCDR\0\0"), Some(RawFormat::Crw));
+ assert_eq!(probe(b"\0MRM\0\x01\0\0"), Some(RawFormat::Mrw));
+ assert_eq!(probe(b"FOVb\x02\0\x02\0"), Some(RawFormat::X3f));
+ for f in [RawFormat::Crw, RawFormat::Mrw, RawFormat::X3f] {
+ assert!(!f.is_supported());
+ }
+ assert!(matches!(decode(b"\0MRM\0\x01\0\0"), Err(RawError::Unsupported(w)) if w.contains("Mrw")));
+ // too short for the CIFF signature
+ assert_eq!(probe(b"II\x1a\0\0\0HEAP"), None);
+ }
+
+ /// An IFD0 with a JPEG pointer but no `ImageWidth` / `ImageLength` (the Kodak KDC layout) is a raw
+ /// container with a preview; a TIFF reader would call it malformed.
+ #[test]
+ fn ifd0_without_dimensions_but_with_a_jpeg_is_a_preview_container() {
+ let jpeg: Vec<u8> = [&[0xffu8, 0xd8, 0xff, 0xc0, 0, 0x0b, 8, 0, 1, 0, 1, 1, 1, 0x11, 0][..], &[0x55; 40], &[0xff, 0xd9]].concat();
+ let off = 8 + 2 + 24 + 4;
+ let mut f = b"II*\0\x08\0\0\0\x02\0".to_vec();
+ for (tag, v) in [(513u16, off as u32), (514, jpeg.len() as u32)] {
+ f.extend_from_slice(&tag.to_le_bytes());
+ f.extend_from_slice(&[4, 0, 1, 0, 0, 0]);
+ f.extend_from_slice(&v.to_le_bytes());
+ }
+ f.extend_from_slice(&[0, 0, 0, 0]);
+ f.extend_from_slice(&jpeg);
+ assert_eq!(probe(&f), Some(RawFormat::OtherTiff));
+ assert!(matches!(decode(&f), Err(RawError::Unsupported(_))));
+ assert_eq!(embedded_preview(&f), Some(jpeg));
+ // no pointer and no sub-IFDs: just a broken TIFF
+ let g = write(&[IfdBuilder::new().with(t::MAKE, Value::Ascii("KODAK".into()))]);
+ assert_eq!(probe(&g), None);
+ }
+
+ /// Compression 99 (not a registered TIFF value; Leaf MOS tiles) marks a raw even without a CFA tag.
+ #[test]
+ fn private_compression_99_is_a_raw() {
+ let mut ifd = rgb_ifd(16, 12);
+ ifd.set(t::COMPRESSION, Value::Short(vec![99]));
+ assert_eq!(probe(&write(&[ifd])), Some(RawFormat::OtherTiff));
+ }
+
#[test]
fn probe_rejects_junk() {
assert_eq!(probe(b""), None);
diff --git a/crates/raw/src/preview.rs b/crates/raw/src/preview.rs
index 42b5d70be..208095e03 100644
--- a/crates/raw/src/preview.rs
+++ b/crates/raw/src/preview.rs
@@ -91,9 +91,13 @@ pub fn embedded_preview(bytes: &[u8]) -> Option<Vec<u8>> {
let j = crate::vendor::raf::header(bytes).ok()?.jpeg?;
return is_dct_jpeg(j).then(|| trim_eoi(j).to_vec());
}
- if crate::probe(bytes) == Some(crate::RawFormat::Cr3) {
+ let format = crate::probe(bytes);
+ if format == Some(crate::RawFormat::Cr3) {
return cr3_preview(bytes).map(|j| trim_eoi(j).to_vec());
}
+ if matches!(format, Some(crate::RawFormat::Crw | crate::RawFormat::Mrw | crate::RawFormat::X3f)) {
+ return scan_for_jpeg(bytes);
+ }
let tiff = Tiff::parse(bytes).ok()?;
let mut found: Vec<&[u8]> = Vec::new();
for ifd in tiff.all_ifds() {
@@ -117,7 +121,94 @@ pub fn embedded_preview(bytes: &[u8]) -> Option<Vec<u8>> {
if let Some(p) = crate::vendor::orf::preview(bytes) {
found.push(p);
}
- found.into_iter().filter(|s| is_dct_jpeg(s)).max_by_key(|s| s.len()).map(|s| trim_eoi(s).to_vec())
+ let best = found.into_iter().filter(|s| is_dct_jpeg(s)).max_by_key(|s| s.len()).map(|s| trim_eoi(s).to_vec());
+ // a TIFF raw we can't decode whose preview no tag points to (Leaf MOS, Epson ERF)
+ best.or_else(|| format.filter(|f| !f.is_supported()).and_then(|_| scan_for_jpeg(bytes)))
+}
+
+/// The end of the DCT JPEG whose SOI is at `soi` (exclusive index after its EOI) and its component count,
+/// walking the marker segments and the entropy-coded data. `None` when it is not a complete, displayable
+/// (baseline or progressive) JPEG, so a stray `D8 FF` in other data is rejected.
+fn jpeg_extent(b: &[u8], soi: usize) -> Option<(usize, u8)> {
+ let mut i = soi + 2;
+ let mut components = None;
+ for _ in 0..4096 {
+ if *b.get(i)? != 0xff {
+ return None;
+ }
+ while *b.get(i)? == 0xff {
+ i += 1;
+ }
+ let m = *b.get(i)?;
+ i += 1;
+ match m {
+ 0xd9 => return components.map(|c| (i, c)),
+ 0x01 | 0xd0..=0xd8 => continue,
+ _ => {}
+ }
+ let len = usize::from(u16::from_be_bytes([*b.get(i)?, *b.get(i + 1)?]));
+ if len < 2 {
+ return None;
+ }
+ match m {
+ 0xc0..=0xc2 => {
+ // precision, height, width, component count
+ let h = u16::from_be_bytes([*b.get(i + 3)?, *b.get(i + 4)?]);
+ let w = u16::from_be_bytes([*b.get(i + 5)?, *b.get(i + 6)?]);
+ if h == 0 || w == 0 || components.is_some() {
+ return None;
+ }
+ components = Some(*b.get(i + 7)?);
+ }
+ 0xc3 | 0xc5..=0xc7 | 0xc9..=0xcb | 0xcd..=0xcf => return None, // lossless, arithmetic, hierarchical
+ _ => {}
+ }
+ i += len;
+ if m == 0xda {
+ // entropy-coded data up to the next marker that is not a stuffed 0xff or a restart
+ loop {
+ i += b.get(i..)?.iter().position(|&x| x == 0xff)?;
+ match *b.get(i + 1)? {
+ 0x00 | 0xd0..=0xd7 => i += 2,
+ 0xff => i += 1,
+ _ => break,
+ }
+ }
+ }
+ }
+ None
+}
+
+/// Last resort for the containers whose structure is not walked (Canon CRW, Minolta MRW, Sigma X3F, TIFF raws
+/// with private blocks such as Leaf MOS or Epson ERF): the largest complete colour DCT JPEG stored as a plain
+/// byte run in the file. A one-component JPEG is skipped (a Canon PowerShot CRW stores its sensor mosaic as one).
+///
+/// Evidence: in the Minolta and Epson files the first byte of the stored preview is not `ff` (it is `00`, `02` or
+/// `ee`) while the rest is a regular JPEG, so a run is found by its `d8 ff` and starts one byte earlier,
+/// with that byte restored to `ff`.
+fn scan_for_jpeg(data: &[u8]) -> Option<Vec<u8>> {
+ let mut best: Option<(usize, usize)> = None;
+ let mut at = 1;
+ while let Some(off) = data.get(at..).and_then(|s| s.iter().position(|&b| b == 0xd8)) {
+ let d8 = at + off;
+ at = d8 + 1;
+ if data.get(d8 + 1) != Some(&0xff) || !matches!(data.get(d8 + 2), Some(0xc0..=0xc4 | 0xdb | 0xe0..=0xef | 0xfe)) {
+ continue;
+ }
+ let start = d8 - 1; // `at` starts at 1, so d8 >= 1
+ if let Some((end, 3)) = jpeg_extent(data, start) {
+ if best.is_none_or(|(s, e)| end - start > e - s) {
+ best = Some((start, end));
+ }
+ at = end;
+ }
+ }
+ let (start, end) = best?;
+ let mut jpeg = data.get(start..end)?.to_vec();
+ if let Some(first) = jpeg.first_mut() {
+ *first = 0xff;
+ }
+ Some(jpeg)
}
/// Canon CR3: the full-size JPEG track (see [`lightcraft_meta::cr3`]), else the `PRVW` / `THMB` boxes.
@@ -242,4 +333,51 @@ mod tests {
file.truncate(at as usize + 100);
assert_eq!(embedded_preview(&file).unwrap(), small);
}
+
+ /// A structurally complete DCT JPEG (no real image data): `nc` components, `n` entropy bytes.
+ fn scan_jpeg(nc: u8, n: usize) -> Vec<u8> {
+ let mut j = vec![0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00];
+ j.extend(std::iter::repeat_n(8u8, 64));
+ j.extend_from_slice(&[0xff, 0xc0, 0x00, 8 + 3 * nc, 8, 0, 16, 0, 24, nc]);
+ for c in 0..nc {
+ j.extend_from_slice(&[c + 1, 0x11, 0]);
+ }
+ j.extend_from_slice(&[0xff, 0xda, 0x00, 6 + 2 * nc, nc]);
+ for c in 0..nc {
+ j.extend_from_slice(&[c + 1, 0]);
+ }
+ j.extend_from_slice(&[0, 63, 0]);
+ j.extend(std::iter::repeat_n(0x55u8, n));
+ j.extend_from_slice(&[0xff, 0x00, 0x12, 0xff, 0xd0, 0x34, 0xff, 0xd9]);
+ j
+ }
+
+ /// Containers whose structure we do not walk give up their largest colour JPEG, found by scanning.
+ #[test]
+ fn scanned_containers_give_the_largest_colour_jpeg() {
+ let (small, big, mosaic) = (scan_jpeg(3, 100), scan_jpeg(3, 900), scan_jpeg(1, 5000));
+ let heads: [&[u8]; 3] = [b"II\x1a\0\0\0HEAPCCDR", b"\0MRM\0\x01\0\0", b"FOVb\x02\0\x02\0"];
+ for head in heads {
+ let mut f = head.to_vec();
+ for part in [&small, &mosaic, &big] {
+ f.extend_from_slice(&[0xff, 0xd8, 0xff, 0x00, 0x00]); // a stray SOI-like run: not a JPEG
+ f.extend_from_slice(part);
+ f.extend_from_slice(&[0u8; 7]);
+ }
+ assert!(crate::probe(&f).is_some_and(|p| !p.is_supported()), "{head:?}");
+ assert_eq!(embedded_preview(&f).as_deref(), Some(&big[..]), "{head:?}");
+ for n in (0..f.len()).step_by(11) {
+ let _ = embedded_preview(&f[..n]);
+ }
+ }
+ // a preview whose first byte was overwritten (Minolta and Epson files store 00, 02 or ee there) is restored
+ let mut f = b"\0MRM\0\x01\0\0".to_vec();
+ f.push(0x02);
+ f.extend_from_slice(&big[1..]);
+ assert_eq!(embedded_preview(&f).as_deref(), Some(&big[..]));
+ // only a one-component JPEG, or none: nothing
+ let mut f = b"FOVb\x02\0\x02\0".to_vec();
+ f.extend_from_slice(&mosaic);
+ assert_eq!(embedded_preview(&f), None);
+ }
}
diff --git a/docs/parity.md b/docs/parity.md
index 42568f974..8bc45152f 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -138,7 +138,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; 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` | 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), CR2 (colour-filter layout from the file's `CR2CFAPattern` tag, issue #85), ARW (pre-2017 bodies: white balance and black level from enciphered maker-note / `SR2SubIFD` data, issue #148; 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), 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-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; 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, NEFs labelled compressed (34713) but stored uncompressed without a `0x0096` table (Z 6 packed 14-bit, D850 12-bit uncompressed), 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`), HEIC/AVIF decode, 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` | 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), CR2 (colour-filter layout from the file's `CR2CFAPattern` tag, issue #85), ARW (pre-2017 bodies: white balance and black level from enciphered maker-note / `SR2SubIFD` data, issue #148; 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), 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-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; 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, NEFs labelled compressed (34713) but stored uncompressed without a `0x0096` table (Z 6 packed 14-bit, D850 12-bit uncompressed), 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", HEIC/AVIF decode, 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; 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; 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`). 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 |
diff --git a/docs/whats-new.md b/docs/whats-new.md
index da89a1b7e..898e3e65c 100644
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@ -17,6 +17,9 @@
are unchanged; photos imported before this change get it when imported again.
- Canon CR3 raws now develop from their sensor data: lossless RAW and C-RAW, checked sample for sample on the EOS
M50, R100 and R8. CR3 files the decoder can't read yet still open from their embedded JPEG, as before.
+- Canon CRW, Minolta MRW, Sigma X3F, Kodak KDC, Leaf MOS and Epson ERF files that LightCraft can't decode yet
+ now import as "preview only" with their embedded JPEG instead of failing. A raw whose data is damaged but whose
+ preview is intact does the same.
- Raw files whose raw data sits in a private block of a TIFF (Phase One / Leaf IIQ, Canon EOS-1D / 1Ds and Kodak DCS
TIFFs) are no longer opened as a thumbnail-sized ordinary image. They are recognised as raws LightCraft can't decode
yet and import as "preview only", with the reason.