-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Crash when loading JP2 image depending on openjpeg version #8784
Comments
In earlier versions, OpenJPEG identified the color space as OPJ_CLRSPC_UNSPECIFIED. Now, it is being identified as OPJ_CLRSPC_GRAY. Pillow doesn't know how to read data from a gray image with 4 channels. I've created #8786 to read the data like a normal RGBA image. I don't suppose you have an image that we could add to our test suite, and distribute under the Pillow license? Something considerably smaller than 10mb would be ideal. |
I'm going to be really honest and say that I'm sorry but I didn't create the file and am not sure how to get you a smaller sample. I took a glance at whether there was a way to make an arbitrary image, but don't have a lot of experience with the JP2000 format to make sure it picks up the 4 layers. The big image came from the NYC GIS Clearinghouse (specifically 2018, Queens Orthoimagery), and to the best of my knowledge is licensed under CC BY 4.0. So that sounds like it might be sufficiently open as a license, could you just crop it to get a smaller file? I gave that a shot myself, but don't have a tool to write the image that is retaining the troublesome formatting issue. If desired, I could help identify one of the tiles that fails but has more detail than the open ocean. |
Thanks. While a natural image is preferable, I was able to add a test to the PR by manually modifying one of our existing images. |
What did you do?
Trying to load and get data from a jp2 image
000137.zip
When working on my dataset, this issue occurred for ~50% of the images, but not for the remainder, so is intermittent.
This worked for me on a previously created python environment, but not a fresh one I created today (with nothing but
conda install pillow
). After some debugging on my end, I was able to determine that the error does NOT occur when downgrading toopenjpeg
version 2.4.0, but does occur withopenjpeg
version 2.5.2. The only difference in the PIL.report is the openjpeg version, and I'm able to repeatably break/fix the issue by upgrading/downgrading openjpeg.I don't know if that makes in an openjpeg problem or a pillow problem, but I'm reporting here because this is the only imaging library I am familiar with, and thus the only place I know how to test and produce the error.
What did you expect to happen?
File loads and yields data
What actually happened?
Code crashes with the following error
What are your OS, Python and Pillow versions?
Code for producing the error on that file:
The text was updated successfully, but these errors were encountered: