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 <noreply@anthropic.com>
This commit is contained in:
Higgs32584andClaude Opus 5.5 authored and aiongg committed 2026-10-24 20:37:15 +00:00
1 parent 5e2d33cd82
commit 425bd319c0
1 file changed
+15
+15
View File
@@ -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();