Save Image with Pillow in Python

Pillow – Save image

To save an image in Python with Pillow library, you can use method. By this way, you can save the image object as an image file in the local file system in required format.

In this tutorial, you will learn how to use function to save an image object as an image file in your local file system.

Steps to save an image

The steps to save an image with Pillow are

  1. Import Image module from Pillow library.
  2. Assume that you have an image object, img, where you have read the image and applied some transformations, or created it from a numpy array, or any such means.
  3. Save this image object using function. Pass the required file name. You may also specify a relative or absolute path. The extension given for the file name is used to format the image.


1. Save image created from a new Image object

In the following example, we create a new Image object using and then save this image using

Python Program

from PIL import Image

# Create image of specific width and height
img  =
        mode = "RGB",
        size = (400, 300),
        color = (255, 0, 0))

# Save the image"red-color-image.jpg")


save image with pillow in python

Image file information

information of image file that has been saved to local file system

2. Save image that has been transformed/updated

In the following program, we read an image from local system, apply some transformations, and then save this resulting image object using using

Python Program

from PIL import Image

# Read the input image
img ="test_image_house.jpg")

# Target image size
size = (200, 250)

# Scale the image
scaled_img = img.resize(size)

# Save the scaled image'scaled_image.jpg')


In this Python Pillow Tutorial, we learned how to save an image object as an image in our local file system, with the help of examples.

Related Tutorials

Code copied to clipboard successfully 👍