LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge PR #498
Brandon Thomas4539014a4297
diff --cc crates/engine/src/media.rsindex a14093de8,a14093de8..3961b5a20--- 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 = 38;++pub const RENDER_CACHE_VERSION: u64 = 39;/// 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.rsindex 1e8f64bbf,7450c774e..b9a05a493--- a/crates/raw/src/vendor/arw.rs+++ b/crates/raw/src/vendor/arw.rs@@@ -485,22 -462,26 +485,30 @@@ fn word16_order(strip: &[u8], bits: u32if n > 0 && over_other == 0 && over_file * 100 > n { other } else { file }}- /// The image area for files without Sony's crop tags (`0x74c7/0x74c8`, written since about 2017): the DNG-style- /// default crop when the raw IFD has one, else the image size the camera records (see [`recorded_size_crop`]).+ /// The raw IFD's DNG-style `DefaultCropOrigin` / `DefaultCropSize`, clipped to the `w × h` frame.-fn dng_default_crop(raw: &Ifd, w: usize, h: usize) -> Option<Rect> {+///+/// `centred` places that recorded-size window in the middle of the frame (on even offsets, keeping the CFA phase)+/// instead of at the left: the packed 12-bit frame (DSLR-A900) has no padding at either edge, and its camera JPEG+/// is centred on the frame.- fn default_crop(raw: &Ifd, mn: Option<&makernote::MakerNote>, exif_size: Option<(u64, u64)>, w: usize, h: usize, centred: bool) -> Rect {- let full = Rect::new(0, 0, w, h);++fn dng_default_crop(raw: &Ifd, w: usize, h: usize, centred: bool) -> Option<Rect> {if let (Some([x, y]), Some([cw, ch])) = (raw.u64s(t::DEFAULT_CROP_ORIGIN).as_deref(), raw.u64s(t::DEFAULT_CROP_SIZE).as_deref())&& *cw > 0&& *ch > 0{- return Rect::new(*x as usize, *y as usize, *cw as usize, *ch as usize).clipped(w, h);+ return Some(Rect::new(*x as usize, *y as usize, *cw as usize, *ch as usize).clipped(w, h));+ }+ None+ }++ /// The image area for files without Sony's crop tags (`0x74c7/0x74c8`, written since about 2017): the DNG-style+ /// default crop when the raw IFD has one, else the image size the camera records (see [`recorded_size_crop`]).+ fn default_crop(raw: &Ifd, mn: Option<&makernote::MakerNote>, exif_size: Option<(u64, u64)>, w: usize, h: usize) -> Rect {+ let full = Rect::new(0, 0, w, h);+ if let Some(crop) = dng_default_crop(raw, w, h) {+ return crop;}match mn.and_then(|m| m.ifd.u64s(MN_FULL_IMAGE_SIZE)).as_deref() {- Some([fh, fw]) => recorded_size_crop((*fw, *fh), exif_size, w, h).unwrap_or(full),+ Some([fh, fw]) => recorded_size_crop((*fw, *fh), exif_size, w, h, centred).unwrap_or(full),_ => full,}}