Closed Zaaaane closed 1 month ago
Just to provide a self-contained code example, I agree that
from PIL import Image
im = Image.new("I;16", (1, 1))
new_im = im.resize((640, 480), resample=Image.Resampling.LANCZOS)
The primary problem is that this worked without error in early July
Considering our last release was on July 1, this doesn't make much sense to me. I tested with 10.3.0, the release before that, and the same error occurs.
This was reported downstream as https://github.com/wagtail/Willow/issues/154
I tested a few Pillow versions and can report this started happening with Pillow 10.3.0. Pillow 10.2.0 is not affected and resizes without error.
Digging further, it appears that in Pillow 10.2.0 the sample image from https://github.com/wagtail/Willow/issues/154 has mode='I'
. In 10.3.0 and later, it is opened as I;16
Looking at the changelog, https://github.com/python-pillow/Pillow/pull/7849 appears to be responsible for that change.
Is this considered a bug / regression? Or should we as end-users do something as a workaround? (use a different resample filter for example)
This is still an open issue, so it is something to be worked on.
The original post here doesn't mention PNGs, so you might be talking about a slightly different scenario. If your problem is #7849, then the simplest workaround would be to convert the image to I mode after opening - im = im.convert("I")
.
Thanks for the response! I realize the original post doesn't mention PNGs, but assuming the original posters' code used to work before I'd say it is likely a similar scenario.
Given I;16
mode support is limited according to the documentation, would you suggest always converting to I
mode before performing image manipulation operations or is support going to be improved in the near future? Trying to gauge what the Willow maintainers should do here - perform the conversion workaround or wait for a new Pillow release.
I've created #8422 to resolve this.
Thanks for fixing @radarhere! I see this has shipped with 11.0.0 and it works perfectly. Are there any plans to backport to the 10.x release series or that now no longer supported?
Thanks for fixing @radarhere! I see this has shipped with 11.0.0 and it works perfectly.
Good to hear!
Are there any plans to backport to the 10.x release series or that now no longer supported?
No, we don't backport anything: only the latest released version is supported.
No, we don't backport anything: only the latest released version is supported.
Alright, thanks. Is this policy documented anywhere? I could not find any clear reference in the documentation.
We have this at https://pillow.readthedocs.io/en/stable/releasenotes/index.html:
Please use the latest version of Pillow. Functionality and security fixes should not be expected to be backported to earlier versions.
Thanks, not sure how I missed that
When attempting to resize a 16 bit image as shown below, a value error appears and crashes the program: "ValueError: image has wrong mode" The image type is "I;16"
The primary problem is that this worked without error in early July and hasn't been touched in a month. When I opened the code today it gave the error even when reverting to a previously stable version. Below is the relevant code inside a custom cropping method. The coord_tup variable is just a tuple that is working as expected
As stated this code used to work fine but when opened this week I get a value error on the line with the resize method, though it will technically work if I change the following
->
I understand through the API documentation that this should default to NEAREST but I could not find anything stating that LANCZOS would not work with 16 bit imaging