From a8d10ccbff03b7a8efce9fa78ecb23e40697b8e2 Mon Sep 17 00:00:00 2001 From: Michael Seele Date: Fri, 13 Sep 2024 10:10:09 +0000 Subject: [PATCH] fix: make set_icc_profile function available --- src/codecs/webp/encoder.rs | 5 +++++ src/image.rs | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/codecs/webp/encoder.rs b/src/codecs/webp/encoder.rs index dfdfbead01..422a36b795 100644 --- a/src/codecs/webp/encoder.rs +++ b/src/codecs/webp/encoder.rs @@ -92,6 +92,11 @@ impl ImageEncoder for WebPEncoder { ) -> ImageResult<()> { self.encode(buf, width, height, color_type) } + + fn set_icc_profile(&mut self, icc_profile: Vec) -> Result<(), UnsupportedError> { + self.inner.set_icc_profile(icc_profile); + Ok(()) + } } impl ImageError { diff --git a/src/image.rs b/src/image.rs index 06a5953e41..59ae08bc6e 100644 --- a/src/image.rs +++ b/src/image.rs @@ -787,6 +787,21 @@ pub trait ImageEncoder { height: u32, color_type: ExtendedColorType, ) -> ImageResult<()>; + + /// Set the ICC profile to use for the image. + /// + /// # Panics + /// + /// Panics if the ICC profile is not implemented for the format. + fn set_icc_profile(&mut self, icc_profile: Vec) -> Result<(), UnsupportedError> { + let _ = icc_profile; + Err(UnsupportedError::from_format_and_kind( + ImageFormatHint::Unknown, + UnsupportedErrorKind::GenericFeature( + "ICC profiles are not supported for this format".into(), + ), + )) + } } /// Immutable pixel iterator