Pillow
Friendly Python Imaging Library fork for opening, manipulating, and saving image files.
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.
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().
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).
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.