How to get image format in Python using PIL

In this article, you’ll see how to get an image format in Python using PIL. You just have to change the location and name of the image. I highly recommend you get the “Computer Vision: Models, Learning, and Inference Book” to learn Computer Vision.

Step 1: Install Pillow library

pip install Pillow

Step 2: Get Image Format in Python

# Import the Pillow library
from PIL import Image

# Read the Image from location
image = Image.open("C:\\AiHints\\man.jpg")

# Print the format of Image
print(image.format)
JPEG

Leave a Comment

Your email address will not be published.