Closed SalOne22 closed 7 months ago
In JPEG ICC profiles are written as a series of app2 markers with some quirky syntax (https://gitlab.com/kornelski/load_image/-/blob/master/src/mozjpeg.rs?ref_type=heads#L19)
You should be able to do it via write_marker.
It would be nice to have a proper API for this in the high level wrapper, so PRs welcome.
If you don't really need a special color profile for wide gamut color, then it's best to convert pixels to sRGB and either not write any profile at all, or write a tiny sRGB one. This is because most JPEG decoders use 8-bit libjpeg API (despite JPEG supporting 12-bit-ish depth) and larger-than-sRGB profiles end up using fewer bits.
Okay, it would be better if this library provided the ability to write an ICC profile. If I do everything right, I will create a new PR here.
I found that the
mozjpeg
library has the ability to write the icc profile to the encoded image, but neithermozjpeg-rust
normozjpeg-sys
provide this functionality. How can I achieve similar results using this wrapper ormozjpeg-sys
crate?Or is the better alternative to apply the icc profile using lcms2 or a similar tool?