Basic Image Operations
- Python Pillow - Working with Images
- Python Pillow - Resizing an Image
- Python Pillow - Flip and Rotate Images
- Python Pillow - Cropping an Image
- Python Pillow - Adding Borders to Images
- Python Pillow - Identifying Image Files
- Python Pillow - Merging Images
- Python Pillow - Cutting and Pasting Images
- Python Pillow - Rolling an Image
- Python Pillow - Writing text on image
- Python Pillow - ImageDraw Module
- Python Pillow - Concatenating two Images
- Python Pillow - Creating Thumbnails
- Python Pillow - Creating a Watermark
- Python Pillow - Image Sequences
Python Pillow Color Conversions
- Python Pillow - Colors on an Image
- Python Pillow - Creating Images With Colors
- Python Pillow - Converting Color String to RGB Color Values
- Python Pillow - Converting Color String to Grayscale Values
- Python Pillow - Change the Color by Changing the Pixel Values
Image Manipulation
- Python Pillow - Reducing Noise
- Python Pillow - Changing Image Modes
- Python Pillow - Compositing Images
- Python Pillow - Working with Alpha Channels
- Python Pillow - Applying Perspective Transforms
Image Filtering
- Python Pillow - Adding Filters to an Image
- Python Pillow - Convolution Filters
- Python Pillow - Blur an Image
- Python Pillow - Edge Detection
- Python Pillow - Embossing Images
- Python Pillow - Enhancing Edges
- Python Pillow - Unsharp Mask Filter
Image Enhancement and Correction
- Python Pillow - Enhancing Contrast
- Python Pillow - Enhancing Sharpness
- Python Pillow - Enhancing Color
- Python Pillow - Correcting Color Balance
- Python Pillow - Removing Noise
Image Analysis
Advanced Topics
- Python Pillow - Creating Animated GIFs
- Python Pillow - Batch Processing Images
- Python Pillow - Converting Image File Formats
- Python Pillow - Adding Padding to an Image
- Python Pillow - Color Inversion
- Python Pillow - M L with Numpy
- Python Pillow with Tkinter BitmapImage and PhotoImage objects
Python Pillow Useful Resources
Python Pillow - Environment Setup
To set up the environment for Pillow, it is recommended to use the pip package manager, as it simplifies downloading and installing Python packages. In this chapter, we will cover how to install the Pillow package on your computer.
Installing Pillow using pip
To install pillow using pip3, just run the below command in your command prompt −
pip3 install pillow
In case, if pip and pillow are already installed in your computer, above commands will simply mention the requirement already satisfied as shown below −
Requirement already satisfied: pillow in .\Lib\site-packages (12.0.0)
How to Install Pillow on MacOS?
Installing Pillow in a Python environment on macOS is straightforward and can be done using package management tools like pip or conda.
Follow the below steps to set up Pillow on macOS −
Open Terminal: We can access the Terminal application on macOS from the Applications folder under Utilities.
Check Python Version: It's a good practice to ensure we have Python installed. To check our Python version to run the following command −
py --version python 3.14.2
Install 'pip' (if not already installed): Most recent versions of Python come with pip pre-installed. To check if pip is installed we can run −
pip --version pip 26.0
If it's not installed, we can install it by downloading the get-pip.py script and running it with Python. Download the script using curl −
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then run the following script.
py get-pip.py
Install Pillow: And finally install Pillow using pip by simply run the following command.
pip3 install Pillow
This command will download and install Pillow and its dependencies.
Now we have successfully set up the Pillow library in our macOS Python environment. We can now start using Pillow for image processing and manipulation tasks.
How to Install Pillow on Windows?
To install the Python Imaging Library (PIL) or its more up-to-date fork on Windows we can follow these steps −
Install Python: If we haven't already installed Python on our Windows system we can do so by following these steps −
Download the latest Python installer for Windows from the official Python website (https://www.python.org/downloads/windows/).
Run the installer and during installation and make sure to check the option Add Python X.Y to PATH (replace X.Y with the Python version we are installing).
Verify Python Installation: Open a command prompt and check that Python has been installed successfully by running the below code −
py --version
Install Pillow (Recommended): Pillow is the modern fork of PIL and is more actively maintained. To install Pillow open a command prompt and run the following command −
pip3 install Pillow
This command will download and install Pillow and its dependencies on our Windows system.
How to Install Pillow on Linux?
Setting up the Pillow library in a Python environment on a Linux-based operating system is similar to the process on macOS. Here are the steps for setting up the environment for Pillow on Linux.
Check Python Installation: Most Linux distributions come with Python pre-installed. To check if Python is installed first open the terminal and run the following code.
py --version
Make sure we have Python 3.x installed as Python 2 is no longer supported.
Install 'pip' (if not already installed): Most recent versions of Python come with pip pre-installed. To check if pip is installed, run the following code.
pip3 --version
If it's not installed we can install it using the package manager specific to our Linux distribution. For example on Debian/Ubuntu-based systems run the following commands based on the OS.
sudo apt-get install python3-pip
On Red Hat/CentOS-based systems
sudo yum install python3-pip
Install Pillow: To install Pillow using pip and run the below command −
pip3 install Pillow
This command will download and install Pillow and its dependencies.
Example - Verifying Installation
To verify that Pillow has been successfully installed in our system, we can create a Python script and import the library −
main.py
from PIL import Image
#Create an Image object
img = Image.new('RGB', (100, 100), color='blue')
#Display the image
img.show()
Output
Save the script with a .py extension and execute it using Python. If Pillow is installed correctly an image window displaying a red square should appear.
Virtual Environment (Optional but Recommended)
It's a good practice to create a virtual environment for our Python projects to keep dependencies isolated. We can create a virtual environment using the following command −
py -m venv myenv
Replace myenv with the name we want for our virtual environment. To activate the virtual environment run the below code −
source myenv/bin/activate
Now we can use our virtual environment to work on Python projects that require Pillow.