transforms::convert_to_srgb handles the sRGB and linear transfers on BT.709 primaries and returns RawError::Unsupported for anything wider:
requires a color-management engine (not yet implemented)
That gap became reachable now that decode reports a container's real colour space (see the colour-tagging work on feat/gallery-roundtrip-gui). Before, every standard decode was forced to SRGB and this branch was effectively dead; an AVIF or HEIC with a colr nclx box now legitimately decodes as DISPLAY_P3 or REC2020, and a caller asking for sRGB pixels gets an error rather than a conversion.
The conversion itself is short — matrix::rgb_to_xyz_matrix, matrix::bradford_adapt, and transfer::eotf_for all exist in gamut-color 2.0.0 — but two pieces are missing upstream:
- a
ColourPrimaries → chromaticities accessor, needed to build the source matrix from a CICP code point;
- an
oetf_for(TransferCharacteristics) inverse, to encode into the destination transfer.
Both are asked for in visualcommons/gamut#376. Blocked on that; per the Upstream-First Policy the primaries table must not be duplicated into rawshift in the meantime.
Related, not blocked
Encode has the mirror-image gap, which needs no upstream work and can be done independently: an image tagged DISPLAY_P3 or REC2020 is written with a synthesised sRGB profile, because rawshift can only synthesise sRGB and the source carried code points rather than a profile. The right fix is to write the code points through to the output container — a PNG cICP chunk, an AVIF colr nclx box — rather than converting or mislabelling. Documented on profile_to_embed in crates/rawshift-image/src/formats/encode.rs.
transforms::convert_to_srgbhandles the sRGB and linear transfers on BT.709 primaries and returnsRawError::Unsupportedfor anything wider:That gap became reachable now that decode reports a container's real colour space (see the colour-tagging work on
feat/gallery-roundtrip-gui). Before, every standard decode was forced toSRGBand this branch was effectively dead; an AVIF or HEIC with acolr nclxbox now legitimately decodes asDISPLAY_P3orREC2020, and a caller asking for sRGB pixels gets an error rather than a conversion.The conversion itself is short —
matrix::rgb_to_xyz_matrix,matrix::bradford_adapt, andtransfer::eotf_forall exist ingamut-color2.0.0 — but two pieces are missing upstream:ColourPrimaries→ chromaticities accessor, needed to build the source matrix from a CICP code point;oetf_for(TransferCharacteristics)inverse, to encode into the destination transfer.Both are asked for in visualcommons/gamut#376. Blocked on that; per the Upstream-First Policy the primaries table must not be duplicated into rawshift in the meantime.
Related, not blocked
Encode has the mirror-image gap, which needs no upstream work and can be done independently: an image tagged
DISPLAY_P3orREC2020is written with a synthesised sRGB profile, because rawshift can only synthesise sRGB and the source carried code points rather than a profile. The right fix is to write the code points through to the output container — a PNGcICPchunk, an AVIFcolr nclxbox — rather than converting or mislabelling. Documented onprofile_to_embedincrates/rawshift-image/src/formats/encode.rs.