-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Resize not allowing filter parameter on 16 bit image #8333
Comments
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) is hitting Pillow/src/libImaging/Resample.c Lines 567 to 577 in 56e3147
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 wagtail/Willow#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 wagtail/Willow#154 has Looking at the changelog, #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 - |
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'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? |
Good to hear!
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:
|
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
The text was updated successfully, but these errors were encountered: