'Why does it return "module 'PIL.Image' has no attribute 'getdata'" when I try to get the rgb value from the image?

So I tried to run this code in order to get image data:

from PIL import Image
pixel = list(Image.getdata())
print(pixel)

And it returns an error: "module 'PIL.Image' has no attribute 'getdata'" Did I call the wrong function or something? And how can I try to fix that?



Solution 1:[1]

You have to call Image.Image.getdata()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Desty