-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
getpixel() should work with list of length 2 #7352
Comments
It's expecting a tuple not a list: https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.getpixel Lines 1149 to 1151 in 643a52a
Lines 1183 to 1185 in 643a52a
|
But the question is why it can't be a list? "argument must be sequence of length 2", list is also a sequence. So behavior or message should be changed. |
Exactly! Thanks, @homm Of course, I would much prefer it it could take any sequence of 2 integers, so we could pass lists, numpy arrays, etc, as long as they have 2 integers. Would probably have been easier if it took 2 integer arguments, but I suppose there's no changing the interface now |
I think that could be done actually. Something like this: def getPixel(self, x, y=None):
if y is None:
xy = tuple(x)
else:
xy = (x, y) |
I've created PR #7355 to allow It does not allow |
Thank you for such quick decision and acting ! |
What did you do?
img.getpixel([473, 653])
What did you expect to happen?
the pixel at that position is returned
What actually happened?
An unexpected error message:
TypeError: argument must be sequence of length 2
But the argument is a sequence of length 2
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: