Skip to content

Commit

Permalink
fix: make set_icc_profile function available
Browse files Browse the repository at this point in the history
  • Loading branch information
misl-smlz committed Oct 7, 2024
1 parent 98ceb71 commit 6329340
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/codecs/webp/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ impl<W: Write> ImageEncoder for WebPEncoder<W> {
) -> ImageResult<()> {
self.encode(buf, width, height, color_type)
}

fn set_icc_profile(&mut self, icc_profile: Vec<u8>) -> Result<(), UnsupportedError> {
self.inner.set_icc_profile(icc_profile);
Ok(())
}
}

impl ImageError {
Expand Down
21 changes: 20 additions & 1 deletion src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::path::Path;
use crate::color::{ColorType, ExtendedColorType};
use crate::error::{
ImageError, ImageFormatHint, ImageResult, LimitError, LimitErrorKind, ParameterError,
ParameterErrorKind,
ParameterErrorKind, UnsupportedError, UnsupportedErrorKind,
};
use crate::math::Rect;
use crate::traits::Pixel;
Expand Down Expand Up @@ -787,6 +787,25 @@ pub trait ImageEncoder {
height: u32,
color_type: ExtendedColorType,
) -> ImageResult<()>;

/// Set the ICC profile to use for the image.
///
/// This function is a no-op for formats that don't support ICC profiles.
/// For formats that do support ICC profiles, the profile will be embedded
/// in the image when it is saved.
///
/// # Errors
///
/// This function returns an error if the format does not support ICC profiles.
fn set_icc_profile(&mut self, icc_profile: Vec<u8>) -> 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
Expand Down

0 comments on commit 6329340

Please sign in to comment.