From 425bd319c09c2aea993ef01177b9dc65b21dbb49 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Sun, 18 Oct 2026 14:25:10 -0400 Subject: [PATCH] JPEG: 12-bit and arithmetic-coded files keep their Photoshop resources The jpeg_ext path set exif, xmp and dpi but not photoshop_resources, so APP13 8BIM blocks (paths, Photoshop settings) were lost on import and re-export. Both decoder paths now fill the same Metadata. Test: a 12-bit JPEG with an APP13 block keeps it. Co-Authored-By: Claude Opus 5.5 --- crates/jpeg/src/tests.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/jpeg/src/tests.rs b/crates/jpeg/src/tests.rs index 3b5acadd..60b005c6 100644 --- a/crates/jpeg/src/tests.rs +++ b/crates/jpeg/src/tests.rs @@ -417,6 +417,21 @@ fn twelve_bit_huffman_block_decodes_to_sixteen_bit() { assert!(px.iter().all(|&v| v.abs_diff(want) <= 1), "{:?} vs {want}", &px[..4]); } +#[test] +fn twelve_bit_jpeg_keeps_its_photoshop_resources() { + // An APP13 `8BIM` block (paths, Photoshop settings) right after SOI, as on the zune-jpeg path. + let resources = b"8BIM\x04\x04\0\0\0\0\0\0".to_vec(); + let mut app13 = b"Photoshop 3.0\0".to_vec(); + app13.extend_from_slice(&resources); + let stream = twelve_bit_huffman_block(); + let mut with = stream[..2].to_vec(); + segment(&mut with, 0xED, &app13); + with.extend_from_slice(&stream[2..]); + assert!(handles(&with)); + let img = crate::decode(&with).unwrap(); + assert_eq!(img.meta.photoshop_resources.as_deref(), Some(resources.as_slice())); +} + /// Where the entropy-coded data of the last scan starts. fn last_scan_data(s: &[u8]) -> usize { let sos = s.windows(2).rposition(|p| p == [0xFF, 0xDA]).unwrap();