Python Pillow is a Python Imaging Library. This library supports many file formats, has a fast internal representation, and performs complex image processing. The popular tools of Python is Pillow. It supports images such as jpeg, jpg, gif, bmp, ppm, and tiff.

Python Library – Pillow

Installing Pillow using pip

python -m pip install pillow

Opening, rotating and displaying an image

Opening an image is a basic operation of the image processing. We import the image module from the Pillow library to load the image. It provides the method.

Example of Opening , rotating and displaying an image

from PIL import Image  

#Open image using Image module  

im =””)  

#Show actual Image  

#Show rotated Image  

imim = im.rotate(90)

Attributes of Image

  • Image.filename
  • Image.format
  • Image.mode
  • Image.size
  • Image.width
  • Image.height
  • Image.palette

Image File Name

This function is use to get the file name or the path name of the image is knows as Image File Name.

Example of Image File Name

image ='rose.jpg')

Image Format

This function returns file format of the image file Just like  jpeg, jpg, gif, bmp, ppm, and tiff.

Example of Images Format

image ='Rose1.PNG')
>>> image.format

Image Mode

It is use to get the pixel format used by the image is knows as Images mode.

Example of Image mode


Images Size

It returns the tuple consist of height and weight of the image is knows as Images Size.

Example of Images Size

(1101, 1005)

Image Width

It returns only the width of the image is knows as Images Width.

Example of Images Width


Image Height

It returns only the height of the image is knows as Images Height.

Example of Images height


Image info

It returns a dictionary holding data associated with the image is knows as Images info.

Example of Images info
{'jfif': 257, 'jfif_version': (1, 1), 'dpi': (300, 300), 'jfif_unit': 1, 'jfif_density': (300, 300), 'exif': b"Exif\x00\x00MM\x00*\x00\x00\x00

Image palette

Example of Images Palette


Working with Images

Reading an Image

Reading and writing images using pillow library is very Easy, with the help of PIL.Image module function.

Syntax, mode=’r’)

Example of Reading an Image

from PIL import Image
image ='rose.jpg')'rose.bmp')
image1 ='rose.bmp')

Saving an Image

The save() function writes an image to file. is knows as Saving an images

Syntax, format=None, **params)

If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.

To know more about Pillow Library Function please Wikipedia Click here

Stay Connected Stay Safe, Thank you

Basic Engineer

Hey Readers! We have more than fifteen years of experience in Software Development, IoT, Telecom, Banking, Finance and Embedded domain. Currently we are actively working on Data Science, ML and AI with multiple market leaders worldwide. Happy Reading. Cheers!


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *