Last modified: Jan 10, 2023 By Alexander Williams

Pillow: Installation and getting started (Python)

Pillow is a powerful library used for processing images. Pillow can:

  • Show or Display Image
  • Get image size
  • Resize Image
  • Rotate Image
  • Convert Image
  • And more...

In this article, we'll see how to install and get started with Pillow.

Pillow Installation

To install the Pillow library, we need to use pip.

# Python2
pip install pillow

# Python3
pip3 install pillow

Getting started with Pillow

After Installing the library, Now let's test it. In the following example, we'll get the size of an image:

from PIL import Image

# Open Image
im = Image.open("py.jpg")

# Size
print(im.size)

Output:

(1395, 864)

Here:

Width is 1395px, Height is 864px