Also hash ICC profile

This commit is contained in:
Laurenz 2025-01-30 19:52:32 +01:00
parent 1e641be5b2
commit 8f884f9f1d
2 changed files with 5 additions and 4 deletions

View File

@ -170,16 +170,17 @@ impl RasterImage {
} }
/// Access the ICC profile, if any. /// Access the ICC profile, if any.
pub fn icc(&self) -> Option<&[u8]> { pub fn icc(&self) -> Option<&Bytes> {
self.0.icc.as_deref() self.0.icc.as_ref()
} }
} }
impl Hash for Repr { impl Hash for Repr {
fn hash<H: Hasher>(&self, state: &mut H) { fn hash<H: Hasher>(&self, state: &mut H) {
// The image is fully defined by data and format. // The image is fully defined by data, format, and ICC profile.
self.data.hash(state); self.data.hash(state);
self.format.hash(state); self.format.hash(state);
self.icc.hash(state);
} }
} }

View File

@ -174,7 +174,7 @@ fn encode_raster_image(image: &RasterImage, interpolate: bool) -> EncodedImage {
(Filter::FlateDecode, data, bits_per_component) (Filter::FlateDecode, data, bits_per_component)
}; };
let compressed_icc = image.icc().map(deflate); let compressed_icc = image.icc().map(|data| deflate(data));
let alpha = dynamic.color().has_alpha().then(|| encode_alpha(dynamic)); let alpha = dynamic.color().has_alpha().then(|| encode_alpha(dynamic));
EncodedImage::Raster { EncodedImage::Raster {