Skip to content

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

Corpus tests: the Z 8 / Z 6II profile tests pair through the lens warp; Hasselblad TIFF previews pass

francoisgn98189d53111b
diff --git a/crates/engine/src/camera_preview.rs b/crates/engine/src/camera_preview.rs
index d074567a7..1d1d7468e 100644
--- a/crates/engine/src/camera_preview.rs
+++ b/crates/engine/src/camera_preview.rs
@@ -3066,10 +3066,14 @@ mod tests {
let bundled: crate::camera_profiles::CameraProfile = serde_json::from_str(json).unwrap();
let used = crate::camera_profiles::get(model).expect("a profile for the model");
assert_eq!(*used, bundled, "a local {model} profile overrides the built-in one; remove it to run this test");
- let raw = lightcraft_raw::decode(&bytes).unwrap();
+ let mut raw = lightcraft_raw::decode(&bytes).unwrap();
assert_eq!(raw.metadata.model.as_deref(), Some(model));
+ // as the app does (`files.rs`): the camera's own lens warp pairs the sensor with its JPEG (Nikon's in-file
+ // distortion for the Z 6II and Z 8), and the lens corrections leave the opcodes before the proxy is binned
+ let lens = lens_geometry(&raw.opcodes.list3);
+ raw.opcodes.list3.retain(|op| !op.is_lens_correction());
let transform = lightcraft_raw::color::camera_transform(&raw, lightcraft_raw::color::as_shot_white_xy(&raw));
- let look = fit_preview(&raw, &bytes, &transform, None).0.expect("fit accepted");
+ let look = fit_preview(&raw, &bytes, &transform, lens.as_ref()).0.expect("fit accepted");
let expected = bundled.matrix().mul(&transform.matrix.inverse().unwrap());
for (row, want) in look.matrix.0.iter().zip(expected.0) {
for (got, want) in row.iter().zip(want) {
diff --git a/crates/raw/tests/corpus.rs b/crates/raw/tests/corpus.rs
index c9a48fb69..76ca70510 100644
--- a/crates/raw/tests/corpus.rs
+++ b/crates/raw/tests/corpus.rs
@@ -44,10 +44,12 @@ fn corpus_raw_decodes() {
let tp = t0.elapsed().as_secs_f64() * 1e3;
// DNG and generic CFA TIFF previews can be absent or uncompressed RGB; other vendor raws embed a JPEG,
// except the Panasonic `.RAW` files of 2005–2007, Canon's explicit HEVC preview tracks and Mamiya MEF.
+ // A Hasselblad 3FR / FFF without a JPEG hands its 8-bit RGB image on as a baseline TIFF (`rgb_preview`).
if let Some(p) = &preview {
let jpeg = p.starts_with(&[0xff, 0xd8]) && p.ends_with(&[0xff, 0xd9]);
let jxl = p.starts_with(&[0xff, 0x0a]) || p.starts_with(b"\0\0\0\x0cJXL ");
- assert!(jpeg || jxl, "{name}: preview is neither a JPEG nor a JPEG XL file");
+ let tiff = fmt == RawFormat::CfaTiff && p.starts_with(b"II*\0");
+ assert!(jpeg || jxl || tiff, "{name}: preview is neither a JPEG, a JPEG XL nor (Hasselblad) a TIFF file");
} else {
let hevc_preview = fmt == RawFormat::Cr3
&& lightcraft_meta::cr3::parse_cr3(&bytes)