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
PreferCicpis correct here — the ICC profile is wrong (or at best, a tone-mapped fallback). UsingPreferIccwould silently apply the wrong transfer function. -
PreferIccfor CICP-native formats loses precision. If the ICC profile’scurvtable 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. -
PreferCicpfor 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.
PreferIccfollows this interpretation.PreferCicpoverrides 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
impl Clone for ColorPriority
Source§fn clone(&self) -> ColorPriority
fn clone(&self) -> ColorPriority
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more