Home > Blockchain >  module 'PIL.Image' has no attribute 'load'
module 'PIL.Image' has no attribute 'load'

Time:10-18

image = Image.load(img)

This line gives me the error. I was trying to load an image.
AttributeError: module 'PIL.Image' has no attribute 'load'

CodePudding user response:

Do this instead:

from PIL import Image
image = Image.open("path_to_image.png")

Replace "path_to_image" with your actual path.

Please read the docs: https://pillow.readthedocs.io/en/stable/handbook/tutorial.html

CodePudding user response:

  1. If you want to get pixel access object, you have to:
img = Image.open("path/to/image")
img.load()
  1. It's not nessessary to use .load method, because the Image class automatically loads an opened image when it is accessed for the first time.
  • Related