PythonPillowv10.4.0
PythonBeginner-friendly

Pillow

Friendly Python Imaging Library fork for opening, manipulating, and saving image files.

imagePILgraphicsthumbnailconvert
The Problem

You need to resize user avatars, add watermarks, convert uploaded PNGs to WebP, extract EXIF data, or generate thumbnails โ€” all server-side without a heavy graphics toolkit.

Mental Model

Pillow represents any image as an Image object with a mode (RGB, RGBA, L), size (width, height), and pixel data. Operations return new Image objects (immutable pipeline). When done, call .save() or .tobytes().

60-second start

Resize and save a thumbnail

from PIL import Image
img = Image.open('photo.jpg')
img.thumbnail((400, 400))  # preserves aspect ratio
img.save('thumb.jpg', quality=85, optimize=True)

Use it when

Resizing/cropping/converting images, compositing overlays, generating thumbnails, basic drawing, reading EXIF metadata, converting between formats.

Skip it when

High-performance batch processing at scale (use ImageMagick or libvips/pyvips). Video processing. Complex image recognition (use OpenCV or ML models).

Alternatives
pyvips10-100x faster for large images, low memory. Steeper API but worth it for scale.
opencv-pythonComputer vision operations, real-time video, more ML-friendly.
wandPython bindings for ImageMagick โ€” broader format support, more effects.

Ready to explore the full API?

See every class, function, and relationship in an interactive graph.