The Python Imaging Library (PIL) is a popular open-source library for the Python programming language, providing image processing capabilities. It's widely used for tasks such as resizing, cropping, and manipulating images. However, PIL is no longer maintained, leading to the creation of its fork, Pillow. This article explores the Pillow package, its features, installation, and usage.
What is Pillow?
Pillow is a fork of the Python Imaging Library (PIL), developed by Alex Clark. It's an enhanced fork that aims to resolve bugs, add new features, and support the latest Python versions. Pillow is designed to provide an easy-to-use interface for opening, manipulating, and saving many different image file formats.
Key Features of Pillow
- Supports a wide range of image file formats, including PNG, JPEG, BMP, GIF, TIFF, and more.
- Offers a wide range of image processing functions, such as resizing, cropping, rotating, flipping, and color conversion.
- Provides text rendering capabilities, allowing you to add text to images.
- Supports advanced features like image enhancement, filtering, and drawing shapes.
- Has a large and active community, ensuring continuous development and support.
Installation
Installing Pillow is straightforward. You can use pip, Python's package installer, to install it. Here's how:

```html
pip install pillow
```
Basic Usage
Here's a simple example of how to use Pillow to open an image, resize it, and save it:
```python from PIL import Image # Open an image file img = Image.open('input.jpg') # Resize the image (maintaining aspect ratio) img_resized = img.resize((300, 300)) # Save the resized image img_resized.save('output.jpg') ```
Advanced Usage
Pillow offers a wide range of advanced features. Here are a few examples:

Adding Text to Images
You can use the draw method to add text to images:
```python from PIL import Image, ImageDraw, ImageFont # Open an image file img = Image.open('input.jpg') # Create a drawing object draw = ImageDraw.Draw(img) # Load a font font = ImageFont.truetype('arial.ttf', 36) # Add text to the image draw.text((10, 10), 'Hello, World!', font=font, fill=(255, 255, 255)) # Save the image img.save('output.jpg') ```
Applying Filters
Pillow provides a range of filters that you can apply to images:
```python from PIL import Image, ImageFilter # Open an image file img = Image.open('input.jpg') # Apply a filter (here, we're using the Gaussian Blur filter) img_filtered = img.filter(ImageFilter.GaussianBlur(radius=5)) # Save the filtered image img_filtered.save('output.jpg') ```
Pillow vs PIL
| Feature | PIL | Pillow |
|---|---|---|
| Active development | No | Yes |
| Python 3 support | No | Yes |
| New features and bug fixes | No | Yes |
As you can see, while PIL is no longer actively maintained, Pillow continues to receive updates, new features, and bug fixes. This makes Pillow a more reliable and up-to-date choice for image processing in Python.



















