How to save an image in Pillow Python

In this article, you’ll see how to save an image in Pillow Python. To read and save an image you just need to change the name and location of the image.

# Import the PIL library
from PIL import Image

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

# Resize the image
resized_img = image.resize((500, 250))

# Save the resized image
resized_img.save("C:\\AiHints\\Resized_Image.jpg")

Output:

Resized_Image
Resized_Image

Recommendation: Computer Vision: Models, Learning, and Inference Book

Leave a Comment

Your email address will not be published.