Issue with loading CMYK jpeg as BufferedImage with CMYK color model
See original GitHub issueHi!
First off, thanks so much for your work on this library and for your immense help on StackOverflow. It made my life a lot easier!
I am using your JPEGImageReader
to load a CMYK JPEG image with an ICC profile. When I read it with the default setup, I get a BufferedImage
with an sRGB color model, and its RGB values correspond to what I get in Photoshop. But my CMYK gamut is not a strict subset of sRGB, so I thought I wanted to keep the image in CMYK color space, so that no clipping to sRGB would occur.
In the tests, I found a method that does this: JPEGImageReaderTest.testReadCMYKAsCMYK
. But the problem I encountered was that the CMYK BufferedImage
generated this way returns different RGB values than the RGB image (using getRGB
). If I’m understanding this correctly, it should return the same values – the only difference being whether the conversion ICC CMYK -> sRGB is done during loading or when calling getRGB
.
I debugged the code to see what might be the issue, and it seems the problem is this line in JPEGImageReader
:
convert = new ColorConvertOp(intendedCS, image.getColorModel().getColorSpace(), null);
the intended CS is the ICC CMYK that’s loaded from the image, but the image
’s color space is different from that and as a result, the image is converted from one CMYK to another, but this conversion is redundant (and incorrect, in the end) if I understand it correctly.
Here’s my Scala code that fails with the image I linked above, I can convert it to Java if that’s an issue https://gist.github.com/the21st/7db788d0417dbff63d6c4ba6a80b5dc8
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
@the21st This bugfix is now included in the official 3.3 release.
Awesome, thank you for such a quick response! 😃