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

Fixed default numresolution for small JPEG2000 images #5540

Merged
merged 1 commit into from Jun 20, 2021

Conversation

radarhere
Copy link
Member

Resolves #3161

A simple version of the problem in that issue is

from PIL import Image
image = Image.new("RGB", (1, 1))
image.save("test.j2k")

At the moment, it gives "OSError: encoder error -2 when writing image file".

Debugging, OpenJPEG is trying to say that the "Number of resolutions is too high in comparison to the size of tiles".

So this PR decreases the number of resolutions to work - unless the user explicitly set num_resolutions through a save argument.

If you're wondering where numresolution is set if Pillow's Python code isn't setting it, the default value for numresolution is 6 in OpenJPEG (or we might set the default to be 6 or 7).

@hugovk hugovk merged commit 8b0244a into python-pillow:master Jun 20, 2021
@radarhere radarhere deleted the numresolution branch June 20, 2021 11:28
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 this pull request may close these issues.

Can't convert images with height / width < 64 to jpeg2000
2 participants