Skip to content

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