libjxl / libjxl

JPEG XL image format reference implementation
BSD 3-Clause "New" or "Revised" License
2.59k stars 251 forks source link

cjxl: Inconsistent rendering intent selection #3186

Open jendalinda opened 7 months ago

jendalinda commented 7 months ago

cjxl assumes that untagged images are in sRGB color space but chooses different rendering intent for different input formats. Here is an overview of input formats and resulting color spaces.

In the Discord discussion, we agreed that the default rendering intent for all untagged input should be Relative.

ledoge commented 4 months ago

I investigated where this inconsistency comes from. For JPEG files, the rendering intent is explicitly set to perceptual here:

https://github.com/libjxl/libjxl/blob/9d5477dc7c2604c596980de1bca072489d4b5aed/lib/extras/dec/jpg.cc#L258 (for completeness, the same line also appears in jpegli here)

For the remaining file types which default to perceptual intent, the color encoding information is set to sRGB here: https://github.com/libjxl/libjxl/blob/9d5477dc7c2604c596980de1bca072489d4b5aed/lib/extras/dec/color_hints.cc#L67-L73 Note that the rendering_intent field is not touched at all, so it remains at its default value of 0, which corresponds to perceptual.

I agree that the default intent should always be relative. Especially when considering the fact that relative sRGB is already defined as the default color encoding in the JPEG XL format specification, i.e. it does not have to be signaled explicitly and the resulting files are a few bytes smaller.