pip install pillow - Steps


Python - Install Pillow

The Pillow library is a powerful image processing library in Python. To install it using pip, follow these steps:

  1. Open your command prompt or terminal.
  2. Run the following command to install Pillow:
pip install Pillow

Example Output:

C:\workspace\python>pip install Pillow
Collecting Pillow
Installing collected packages: Pillow
Successfully installed Pillow-5.4.1

Once the installation is complete, you can start using the Pillow library in your Python programs.

Using Pillow in Python

After successfully installing Pillow, you can import the library to begin working with image processing tasks. Below is an example of how to import and use the library:

from PIL import Image

# Open an image file
img = Image.open('image.jpg')
img.show()

In this example, we import the Image class from the PIL module and use the Image.open() method to load an image. The img.show() method opens the image in the default viewer.

The Pillow library provides many powerful features for image manipulation, including resizing, cropping, rotating, and much more.

Common Uses of Pillow

  • Opening and saving image files in different formats (JPEG, PNG, etc.)
  • Image resizing and transformation
  • Image filtering and enhancement (e.g., applying blur or sharpen effects)
  • Drawing text and shapes on images

Summary

In this guide, we covered how to install the Pillow library in Python using pip. After installation, you can start using Pillow for various image manipulation tasks in your Python programs.


Python Libraries