Skip to content
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

Saving a CMYK image as .jp2/.j2k fails #8062

Open
sl2c opened this issue May 15, 2024 · 2 comments · May be fixed by #8592
Open

Saving a CMYK image as .jp2/.j2k fails #8062

sl2c opened this issue May 15, 2024 · 2 comments · May be fixed by #8592
Labels

Comments

@sl2c
Copy link

sl2c commented May 15, 2024

When running

Image.open('cmyk.tif').save('out.jp2')

I get:

OSError: encoder error -2 when writing image file

Same with writing to '.j2k'. Same with other CMYK images I tried. I am using Pillow v. 10.1.0.

cmyk.tif.zip

@radarhere
Copy link
Member

I've created uclouvain/openjpeg#1529 as the first step in saving JP2 CMYK images.

Without the colour specification box of JP2, it doesn't seem possible to have a CMYK J2K image.

https://community.intel.com/t5/Intel-Integrated-Performance/JPEG2000-and-CMYK-Data-Not-RGB/td-p/862891

JPEG 2000 encoding doesn't support CMYK coding, mostly because it's an extension of JP2 file container (part 2 of the standard)

https://newsgroup.xnview.com/viewtopic.php?t=29274

the JPEG-2000 standard does not specify any means for encoding color space information in a JPEG-2000 code stream, the decoder must make certain assupmtions about the color space of an image. If accurate color representation is important, the JPEG-2000 code stream format should not be employed. The JPEG-2000 JP2 format should be used instead.

@radarhere radarhere added the JPEG label May 16, 2024
@radarhere radarhere linked a pull request Dec 10, 2024 that will close this issue
@radarhere
Copy link
Member

radarhere commented Dec 10, 2024

OpenJPEG 2.5.3 has now been released, so I've created #8592 to add CMYK JP2 saving.

#8591 has updated the version that Pillow uses in wheels, but if you install Pillow some other way, then you should note that this will need OpenJPEG 2.5.3 to be installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants