463079 JPEG-XL: Prevent crashing when opening CMYK(A) files
Attempt to fix crash on JXL CMYK import. AFAIK, we're still not supporting it yet: https://github.com/libjxl/libjxl/issues/1719
It looks like the crash originated when we try to load a JXL CMYK image, jxl decoder still gives num_color_channels == 3
, assigning it to RGBA model in our code and tried to apply the CMYK ICC, thus throws out the segfault crash. This MR attempts to throw out import error instead of crashing the whole Krita. This MR attempts to enable support for both import and export on CMYK JPEG-XL files.
This JXL CMYK detection also can be a foundation for our future works if we're ready to support it. I also personally tried to import using our existing JxlDecoderSetImageOutCallback
and setting it to CMYKA
color model but still no avail, black K
channel is still missing indicating the need for separate buffer for it...
Test Plan
- Import/Open CMYK JPEG-XL file, check whether Krita still crashes or not.
-
- CMYK JXL files are available from BUG: 463079 and https://github.com/libjxl/conformance/tree/master/testcases/cmyk_layers
- Export to CMYK JPEG-XL file, check if it survives roundtrip.
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.