Skip to main content

ColorPriority

Enum ColorPriority 

Source
pub enum ColorPriority {
    PreferIcc,
    PreferCicp,
}
Expand description

Controls which transfer function metadata the CMS trusts when building a transform.

ICC profiles store transfer response curves (TRC) as curv or para tags — lookup tables or parametric curves baked into the profile. Modern container formats (JPEG XL, HEIF/AVIF, AV1) also carry CICP transfer characteristics — an integer code that names an exact mathematical transfer function (sRGB, PQ, HLG, etc.).

When both are present, they should agree — but in practice, the ICC TRC may be a reduced-precision approximation of the CICP function (limited by curv table size or para parameter quantization). The question is which source of truth to prefer.

§Which priority to use

  • Standard ICC workflows (JPEG, PNG, TIFF, WebP): use PreferIcc. These formats don’t carry CICP metadata; the ICC profile is the sole authority.

  • CICP-native formats (JPEG XL, HEIF, AVIF): use PreferCicp. The CICP code is the authoritative description; the ICC profile exists for backwards compatibility with older software.

§Bugs and pitfalls

  • CICP ≠ ICC is a real bug. Some encoders embed a generic sRGB ICC profile alongside a PQ or HLG CICP code. Using PreferCicp is correct here — the ICC profile is wrong (or at best, a tone-mapped fallback). Using PreferIcc would silently apply the wrong transfer function.

  • PreferIcc for CICP-native formats loses precision. If the ICC profile’s curv table is a 1024-entry LUT approximating the sRGB function, you get quantization steps in dark tones. The CICP code gives the exact closed-form function — no quantization, no table interpolation error.

  • PreferCicp for pure-ICC formats is harmless but pointless. If the profile has no embedded CICP metadata, the CMS ignores this flag and falls back to the TRC. No wrong output, just a wasted branch.

  • Advisory vs. authoritative. The ICC Votable Proposal on CICP metadata in ICC profiles designates the CICP fields as advisory. The profile’s actual TRC tags remain the normative description. PreferIcc follows this interpretation. PreferCicp overrides it for formats where the container’s CICP is known to be authoritative.

Variants§

§

PreferIcc

Prefer the ICC profile’s own curv/para TRC curves. Ignore any embedded CICP transfer characteristics.

Correct for standard ICC workflows (JPEG, PNG, TIFF, WebP) and any situation where the ICC profile is the sole color authority.

§

PreferCicp

Allow the CMS to use CICP transfer characteristics when available.

Faster (closed-form math vs. LUT interpolation) and more precise (no table quantization error). Correct only for formats where CICP is the authoritative color description: JPEG XL, HEIF, AVIF.

Trait Implementations§

Source§

impl Clone for ColorPriority

Source§

fn clone(&self) -> ColorPriority

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColorPriority

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ColorPriority

Source§

fn default() -> ColorPriority

Returns the “default value” for a type. Read more
Source§

impl Hash for ColorPriority

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ColorPriority

Source§

fn eq(&self, other: &ColorPriority) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ColorPriority

Source§

impl Eq for ColorPriority

Source§

impl StructuralPartialEq for ColorPriority

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.