How to read image in Python using PIL

You can read an image in Python using PIL by following the given steps. If you want to learn Computer Vision then I will highly recommend you to read This book.

How to read image in Python using PIL
How to read image in Python using PIL

Step 1

If Pillow library is not installed, then first install it using this code.

pip install Pillow

Step 2

The image should be in the same folder in which the code file is running. Otherwise, add the location before the image name.

# Import the PIL library
from PIL import Image

# Read the Image
image = Image.open("man.jpg")

# Show the Image
image.show()

# Print type of Image
print(type(image))

Output:

<class 'PIL.JpegImagePlugin.JpegImageFile'>
Output

Free Learning Resources

Leave a Comment

Your email address will not be published.