-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to export JXL images #7097
base: dev
Are you sure you want to change the base?
Conversation
Add workflow_dispatch to CodeQL workflow
Fix for older libjxl versions Fix CodeQL errors
Do you think the output profile issue is a problem with RawTherapee or GIMP? If it's a RawTherapee issue, then I think it should be addressed in this pull request unless the jxl specification says images without color profile information should be assumed to be in sRGB. |
JPEG XL is very weird when it comes to color management (it takes on tasks it shouldn't IMHO) - if you do lossy compression, data is stored internally in float and "XYB" color space. The decoder can then decode it straight to any color space on the other end (sRGB usually), unless the "original" target profile is requested by the decoder (which had to be stored at encoding time of course, either as ICC or JPEG XL color space enum), and that is out of the control of the encoding app (which is the weird part, at least for me). For lossless compression, one can/should keep the "original" color profile throughout of course. |
The best solution at this time, for cross-application and cross-version libjxl, would probably be to force sRGB when exporting jxl, but I do not know how. If images are intended only for use with RawTherapee with a single version of libjxl, the current state of this PR is very close to working as expected. When exporting and importing across different versions of libjxl (0.7.x, 0.10.x), images may not display correctly. A workaround for both RawTherapee and GIMP is to assign the correct profile after opening. Cross-version problems may be related to 0.10.x converting ICC profiles to internal representation when saving, and not delivering an ICC profile when images use internal representation (color space enum). So an image viewer, for instance, will display the image incorrectly because libjxl doesn't give it an ICC profile. |
Why would you ever want to force sRGB?! It's a narrow gamut. On export, you just need to supply libjxl w/ the profile of the data you're feeding it (ICC or enum).
No, it is because it didn't ask for one from lbjxl upon decoding. That's why it's weird, it's not implicit. |
For cross app compatibility. Nothing I currently have installed works with non-sRGB jxl, except
I'm feeding it ICC. The images are coming out with enum set.
What do I need to change to ask for one? Right now, I'm expecting the decoder to tell me whether one is available. RawTherapee/rtengine/imageio.cc Lines 899 to 936 in 13a07a5
|
Yes, that's the way. But in recent libjxl versions (can't remember when this behaviour was added exactly), that doesn't only mean an ICC profile was actually embedded at encoding - it just means the decoder can generate and supply one on the fly, which it should do in most cases, as most internally stored enum combos are known: |
Using libjxl 0.10.x, sRGB and P3 JXLs exported with this PR seem to use JXL enums, no embedded ICC. They are displayed correctly in RawTherapee with this PR (made adjustment to import), darktable, and GIMP 2.99/3.x. The P3 JXL did not display correctly in GIMP 2.10. Probably problem with the plugin or limitations of GIMP 2.10 libraries. Workaround is to assign the correct profile after import. Compiles with libjxl 0.7.x. Can export and import images. Issues mainly with non-sRGB profiles. Not doing further testing because fixing 0.7.x seems to break 0.10.x, and vice versa. Fixing thumbnail display could be left for another PR, but may be hopeless, especially with old libjxl. To add metadata, Exif blobs are needed. If someone tells me how to get them, I can add to this PR. Otherwise, could leave for another PR. Exiv2 does not support writing to JXL. Updating CLI options, I could look at next, or leave for another PR. |
0.11.x is expected in the near future according to libjxl/libjxl#3700 (comment). |
I tested RawTherapee built with libjxl 0.10.3, but run with libjxl-git 0.10.3.r227.g5ddb303a. No difference in previously observed behavior. Images open correctly with this PR, darktable, and GIMP 2.99/3.x. I did not rebuild the applications because of how time consuming it would be, but don't think it matters. If libjxl 11.x is released before this PR is ready for merge, should workflows be updated as part of this PR or in a separate PR? Wasn't paying close attention earlier, but darktable thumbnails are correct. So it may be worth looking at for inspiration. Somewhat related, had idea to use libjpegli to expand bit depth of imported jpegs. #7125 |
For adding EXIF, maybe ExifParser::encode() can help. |
Closes #6273. Related #6367, #6773.
Main problem is color management. When saving with output profile other than sRGB (eg, P3):
Potential improvements to add or leave for another PR...
-j*
options are forjpeg
.Following seem okay:
WITH_JXL=no
.