//! ICC profile metadata needed by PDF image color spaces. pub(super) fn intent(profile: &[u8], components: u8) -> Option<&'static str> { let header = profile.get(..128)?; let size = u32::from_be_bytes(header[..4].try_into().unwrap()) as usize; let signature: &[u8] = match components { 1 => b"GRAY", 3 => b"RGB ", 4 => b"CMYK", _ => return None, }; if size != profile.len() || &header[16..20] != signature || &header[36..40] != b"acsp" { return None; } let intent = u32::from_be_bytes(header[64..68].try_into().unwrap()); [ "Perceptual", "RelativeColorimetric", "Saturation", "AbsoluteColorimetric", ] .get(intent as usize) .copied() }