In this article, we will see how to save image in Python.
The library used for image editing is the PIL library. It is an imaging library. The
Image class is used to represent a PIL image. Using this class we can load images from files, create new images, etc.
Image.open() opens the specified image to create an image object.
Image.save() saves the image under the given filename.
from PIL import Image # an Image object img_obj = Image.open(r"C:/Users/user/Pictures/IMG-20191224-WA0005.jpg") img_obj.save("flake.jpg")
In this program, first we have imported the PIL library and the Image module. Then using
Image.open() we have opened the required image into an image object. Later using
Image.save(), we’ve saved this image object under a new name flake.jpg in some other directory. After the code being executed successfully, you can see a image file saved in the specified directory.