Skip to content

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

Merge PR #689

Claude31734dea860d
diff --cc crates/engine/src/media.rs
index c88a7654d,515dbf5fb..bbd38f05c
--- a/crates/engine/src/media.rs
+++ b/crates/engine/src/media.rs
@@@ -62,7 -62,7 +62,7 @@@ impl SettingsHashes
}
/// Bump when the pipeline's output changes, to invalidate cached thumbnails.
- pub const RENDER_CACHE_VERSION: u64 = 54;
-pub const RENDER_CACHE_VERSION: u64 = 44;
++pub const RENDER_CACHE_VERSION: u64 = 55;
/// 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 --cc crates/raw/src/vendor/arw.rs
index 4295b0b8c,8c6b2d5eb..18e51e08d
--- a/crates/raw/src/vendor/arw.rs
+++ b/crates/raw/src/vendor/arw.rs
@@@ -29,13 -29,10 +29,14 @@@
//! ([`word16_order`]). Measured on the CC0 DSC-R1 (raw.pixls.us 3221): StripByteCounts 20780544 = 3984×2608×2; read
//! big-endian the maximum is 16368 and the image is smooth (neighbour roughness 0.012 against 0.249), read
//! little-endian the maximum is 65340 (noise). Black stays the default 512 (the masked columns read 511.4) and white
- //! comes from the data. The crop and white balance are NOT addressed here: the file has no maker-note `FullImageSize`
- //! and no plain WB tag (they live in its `SR2SubIFD`), so it opens uncropped with unit multipliers.
+ //! comes from the data. The file has no maker-note `FullImageSize` and no plain WB or crop tag; they live in its
+ //! `SR2SubIFD` (key `63 be 01 3e`, see [`super::sr2`]): black `0x7300`, as-shot WB `0x7303` (G, R, B, G) and the crop
+ //! `0x74c3` (x0, y0, x1, y1), each read only when no other source exists.
//!
+//! Packed 12-bit ARW (DSLR-A900; Compression 32767 but BitsPerSample 12 and a strip of exactly width × height × 1.5
+//! bytes): plain 12-bit samples, two per three bytes, least-significant-bit first ([`unpack_row12`]); linear, black 128
+//! (512 on the 14-bit scale), CFA from the file's own pattern tag, crop centred on the frame (see [`default_crop`]).
+//!
//! Also: uncompressed 16-bit ARW, and lossless-compressed ARW (Compression 7, ILCE-7M4 and later): LJ92 tiles whose
//! frames hold one 2×2 CFA cell per four-component sample ([`read_quad_tiles`]). Other lossless-JPEG layouts go
//! through the generic TIFF path.
@@@ -665,7 -633,9 +687,9 @@@ pub(crate) fn decode(bytes: &[u8], mode
(Some([x, y]), Some([cw, ch])) if *cw > 0 && *ch > 0 => Rect::new(*x as usize, *y as usize, *cw as usize, *ch as usize).clipped(w, h),
_ => {
let exif_size = tiff.exif().and_then(|e| Some((e.u64(t::PIXEL_X_DIMENSION)?, e.u64(t::PIXEL_Y_DIMENSION)?)));
- default_crop(raw, mn.as_ref(), exif_size, w, h, packed12)
- let crop = default_crop(raw, mn.as_ref(), exif_size, w, h);
++ let crop = default_crop(raw, mn.as_ref(), exif_size, w, h, packed12);
+ // no crop from any other source: the old SR2SubIFD's
+ if crop == Rect::new(0, 0, w, h) { sr2().and_then(|s| sr2_old_crop(s, w, h)).unwrap_or(crop) } else { crop }
}
};
let mut metadata = lightcraft_meta::from_tiff(&tiff);