From a47b78256c6acf3d7fdc4bc7cfbc25c373eac522 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 01:15:30 -0500 Subject: [PATCH] Expose shared embedded ICC extraction --- crates/image-codecs/src/inspection.rs | 8 ++++++++ crates/image-codecs/src/lib.rs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/image-codecs/src/inspection.rs b/crates/image-codecs/src/inspection.rs index 922cc5ce1..e263eea3a 100644 --- a/crates/image-codecs/src/inspection.rs +++ b/crates/image-codecs/src/inspection.rs @@ -3,6 +3,14 @@ use crate::error::CodecError; use crate::{ChannelLayout, DecodeOptions, Format, Limits, SampleType, decode_with}; +/// Return an embedded ICC profile using the selected format decoder. +/// +/// This fully decodes the image; callers that already need the pixels should read `Image::meta.icc` +/// from that decode instead of invoking this helper separately. +pub fn embedded_icc(bytes: &[u8]) -> Result>, CodecError> { + Ok(decode_with(bytes, &DecodeOptions::default())?.icc) +} + /// The source pixel model reported by an image container, before decode normalizes it. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RasterColorType { diff --git a/crates/image-codecs/src/lib.rs b/crates/image-codecs/src/lib.rs index 335692a47..865e59865 100644 --- a/crates/image-codecs/src/lib.rs +++ b/crates/image-codecs/src/lib.rs @@ -48,7 +48,7 @@ pub use crate::image::{ ChannelLayout, CryptomatteBuffer, CryptomatteLayer, DecodeWarning, DeepChannel, DeepImage, ExrChannelInfo, ExrPartInfo, ExtraSample, Image, MAX_EXTRA_SAMPLES, Metadata, SampleType, convert_samples, }; -pub use crate::inspection::{RasterColorType, RasterInspection, ToneClass, classify_tone, inspect_raster}; +pub use crate::inspection::{RasterColorType, RasterInspection, ToneClass, classify_tone, embedded_icc, inspect_raster}; pub use crate::options::{ DdsCompression, DdsOptions, DecodeOptions, DpxBits, EncodeOptions, ExrCompression, JpegFormat, Limits, PngCompression, PngStereo, TIFF_PYRAMID_MIN, TiffCompression,