ConfigsApr 29, 2026·3 min read

Pillow — The Python Imaging Library Fork

Friendly fork of PIL that adds modern Python support, new file formats, and active maintenance for image processing in Python.

Introduction

Pillow is the actively maintained fork of the Python Imaging Library (PIL). It provides an easy-to-use interface for opening, manipulating, and saving images in dozens of formats. Pillow is the de facto standard for image handling in the Python ecosystem, underpinning data science pipelines, web applications, and automation scripts.

What Pillow Does

  • Opens and saves images in 30+ formats including JPEG, PNG, TIFF, WebP, GIF, and BMP
  • Performs image transformations: resize, crop, rotate, flip, and affine transforms
  • Applies filters and enhancements: blur, sharpen, contrast, brightness, and edge detection
  • Draws text, shapes, and overlays onto images using the ImageDraw module
  • Provides pixel-level access for custom image processing algorithms

Architecture Overview

Pillow wraps optimized C libraries (libjpeg, libpng, zlib, libtiff, libwebp) behind a Pythonic API. The core Image class lazily decodes pixel data on first access, keeping memory usage low when only metadata is needed. Operations chain through a pipeline that avoids unnecessary copies. The library supports multiple pixel formats (RGB, RGBA, L, CMYK, palette) and converts between them transparently.

Self-Hosting & Configuration

  • Install via pip; binary wheels include bundled C dependencies for most platforms
  • For custom builds, install system libraries (libjpeg-dev, zlib1g-dev) then pip install from source
  • Control JPEG quality, PNG compression level, and WebP settings through save() parameters
  • Set Image.MAX_IMAGE_PIXELS to guard against decompression bomb attacks
  • Use ImageFile.LOAD_TRUNCATED_IMAGES to handle partially downloaded images gracefully

Key Features

  • Format support for JPEG, PNG, WebP, GIF, TIFF, BMP, ICO, PDF, and many more
  • EXIF metadata reading and writing for photo management workflows
  • Animated GIF and WebP creation with frame-by-frame control
  • ImageFont module renders TrueType and OpenType text onto images
  • Seamless integration with NumPy arrays for bridging to scientific and ML libraries

Comparison with Similar Tools

  • OpenCV — full computer vision library with video support; Pillow is simpler for basic image I/O and manipulation
  • scikit-image — scientific image processing built on NumPy; Pillow handles format I/O that scikit-image delegates to it
  • ImageMagick — CLI-based image processing; Pillow provides a native Python API without subprocess calls
  • Wand — Python bindings for ImageMagick; Pillow has a lighter footprint and broader Python ecosystem adoption
  • rawpy — specialized for RAW camera files; Pillow covers common consumer formats

FAQ

Q: What is the difference between PIL and Pillow? A: Pillow is a maintained fork of the original PIL library, which is no longer developed. Pillow is API-compatible and adds Python 3 support, new formats, and security fixes.

Q: Can Pillow handle very large images? A: Yes, but set Image.MAX_IMAGE_PIXELS appropriately. For extremely large images (gigapixel), consider tiled processing with libraries like pyvips.

Q: Does Pillow support GPU acceleration? A: No. Pillow runs on CPU. For GPU-accelerated image processing, use OpenCV with CUDA or NVIDIA DALI.

Q: How do I convert between Pillow and NumPy? A: Use numpy.array(img) to get a NumPy array from a Pillow Image, and Image.fromarray(arr) to convert back.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets