ICC profile not working (invalid color profile created)
Opened this issue · 9 comments
Environment:
- Test files: DisplayCAL ICC Color Management & Rendering Intent Test
- jpeg-xl version: 0.3.7
Steps to reproduce:
- Convert the jpg files to jxl by
cjxl
. - Open the JXL (e.g.
ICC Rendering Intent Test (cLUT only).jxl
) bygwenview
. - Open the JPG and PNG by
gwenview
.
Observed result:
Although the JXL is displayed, the colors are wrong because the ICC profile cannot be applied.
JPG and PNG versions have no such problem.
Console output:
qt.gui.icc: fromIccProfile: Unsupported ICC profile - not three component matrix based
invalid color profile created
full image, format=4
Qt doesn't support all ICC profiles yet.
gwenview does its own color management but it is limited to the most popular formats.
I took a normal PNG file (correct-colors.png
) and assigned the Swapped Red and Green profile (which is provided by colord
) via GIMP, and exported it to wrong-colors.png
. I then converted wrong-colors.png
to JXL (wrong-colors.jxl
).
When using Gwenview to open the JXL, no error message is displayed:
full image, format=4`
However, the colors are not as expected!
Gwenview correctly applies the profile for wrong-colors.png
, but it does not apply the profile for wrong-colors.jxl
, so wrong-colors.jxl
looks the same as correct-colors.png
.
(Note: After applying the swap Red and Green profile, orange lines become green lines, and light blue becomes light purple.)
Which component (Qt, JXL library, etc.) causes this issue?
P.S. I am using exiv2
from latest git. The issue is present with both unpatched and patched kfilemetadata
. Gwenview is stock (unpatched).
There are two possibilities:
1)
gwenview could be patched so it will do its own color management like it does for jpeg and png
https://invent.kde.org/graphics/gwenview/-/blob/master/lib/cms/cmsprofile.cpp#L149
convert pixel data inside my plug-in to sRGB profile but it would require new dependency, there will be performance penalty and the data conversion could be an issue for some users.
I found that a WebP image with color profile will not display in correct colors in Gwenview, so apparently Gwenview is missing support for other formats.
Regarding solution 1, is it easy to patch Gwenview?
I have impression that it should be easy, following functions should be used:
QImageReader::read()
QImage::colorSpace()
QColorSpace::iccProfile()
cmsOpenProfileFromMem
I recommend to re-use existing QImageReader reader(&buffer, mFormatHint);
if possible. Creating another QImageReader will trigger another decoding pass and slows image opening.
If we can use the above functions, does that mean Gwenview can read the profile from various image formats in a generic way (eliminates the need of Profile::loadFromXxxData
for each format)?
Other formats could be supported via those functions too but only those with Qt plug-ins and using QColorSpace class to signal what profile us used.
I suggested changes to gwenview: https://invent.kde.org/graphics/gwenview/-/issues/7
I am closing this issue, because nothing more will be done on plugin's side.
You can correctly view JXL files in digiKam master (future 7.3 version probably) when you manually enable jxl
extension in digiKam.
Thanks for reporting this, the testfile was very valuable.
FYI, gwenview from master now applies color management for JXL images with 8bit depth.