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
Image.point(lut, mode) no longer accepts numpy.arrays #439
Comments
@minkwe Can you trace this regression back in the commit history (assuming numpy.array should still be supported)? |
@aclark4life You can find the change at the bottom of da1d715 Essentially operator.isSequenceType was replaced with collections.Sequence probably to support Python 3 which does not have operator.isSequenceType. But I discovered this because it broke my code when I moved from Pillow 1.7.8 to Pillow 2+:
There is an outstanding bug request to make numpy a collections.Sequence numpy/numpy#2776. However it would be nice if Pillow continues to support numpy.ndarrays until this is fixed or in the alternative the release notes of Pillow should contain a backward incompatibility warning. |
OK so Python 3 compat broke numpy.array support, thanks. Is there an operator.isSequenceType equivalent in Python 3, anyone know? |
Looks like this is the only place in the code where we're likely to get a numpy.array that's going to trigger this bug. (the other mention is in the resolution tag in tiffs, and I just don't see that being a problem). I'd propose adding an isSequenceType function into the _util.py file that would specifically check for numpy.arrays. |
+1 |
Also, we need test coverage on this. And the 16bit lut issue as well. |
What about checking if lut is callable and then assuming it is a sequence. Currently the code checks for sequence first and then assumes it is a function. |
@minkwe that would work too. though, as |
In PIL 1.1.7, you could pass a numpy.array as a look-up-table. However the current version 2.2.1 breaks that behavior by allowing only collections.Sequence instances, which a numpy.array is not.
The text was updated successfully, but these errors were encountered: