Extensive Format Support
Seamlessly open, read, and write JPEG, PNG, WEBP, GIF, TIFF, BMP, ICO, PSD, and 25+ more formats. Batch-convert massive ML datasets with single-line format migrations.
Python Pillow is the industry standard for image processing in Python. Open, resize, filter, convert, draw, and analyze images with a clean, expressive API — all in pure Python.
Everything you need to manipulate local and remote images inside Python pipelines.
Seamlessly open, read, and write JPEG, PNG, WEBP, GIF, TIFF, BMP, ICO, PSD, and 25+ more formats. Batch-convert massive ML datasets with single-line format migrations.
Resize, crop, rotate, flip, and transpose images. Use high-quality Lanczos resampling to retain visual fidelity at any scale.
Apply BLUR, CONTOUR, SHARPEN, EDGE_ENHANCE, FIND_EDGES, EMBOSS, and custom kernel filters via the ImageFilter module.
Draw polygons, arcs, rectangles, and overlay TrueType/OpenType text with ImageDraw. Automate watermarks, captions, and thumbnail overlays at scale.
Pillow's power comes from its modular design. Each module handles a distinct area of image processing.
The central class. Open, create, save, convert, resize, and transform images. Every pipeline starts here.
open()save()resize()crop()convert()
Draw 2D graphics onto images. Supports lines, rectangles, ellipses, polygons, and text rendering.
line()rectangle()ellipse()text()
Pre-built filters including GaussianBlur, UnsharpMask, MedianFilter, and custom kernel convolutions.
GaussianBlurSHARPENEDGE_ENHANCE
Adjust Brightness, Contrast, Color saturation, and Sharpness using a simple factor-based API.
BrightnessContrastColorSharpness
High-level operations: autocontrast, equalize, flip, grayscale, pad, fit, contain, and invert.
autocontrast()equalize()fit()grayscale()
Load TrueType (TTF) and OpenType (OTF) fonts for high-quality text rendering in generated images.
truetype()load_default()getbbox()
Channel operations: add, subtract, multiply, difference, composite — pixel-level arithmetic between images.
add()multiply()difference()
Compute statistics (mean, median, RMS, standard deviation, extrema) over entire images or pixel bands.
meanmedianrmsextrema
Zero to processing in minutes. Select your operating system or package manager below.
Windows supplies pre-compiled binary wheels — no C++ compiler required. Run in PowerShell or Command Prompt.
Open the Python REPL and ensure PIL imports cleanly.
Pillow provides native universal wheels for Apple Silicon (M1, M2, M3, M4) and Intel Macs.
For advanced format support (TIFF, JPEG 2000, WebP, AVIF) when compiling from source:
Install essential development libraries for JPEG and PNG support on Ubuntu/Debian:
Installs the latest Pillow wheel into your Python environment.
Install system-wide package via Ubuntu repository:
Recommended for Anaconda, Miniconda, and Miniforge environments via conda-forge:
In Anaconda Navigator: go to Environments > search pillow > Check > Click Apply.
Recommended: keep your project dependencies clean and isolated.
With the virtual environment active, install Pillow normally.
All 30+ image formats supported across read, write, and animation dimensions.
The most frequently used Python instructions for daily image processing tasks.
Load an image and verify its dimensions, format, and mode.
Display in default OS viewer or inline inside Jupyter Notebook.
Convert to 8-bit grayscale ('L') or pure 1-bit binary ('1').
Resize preserving aspect ratio in-place (no upscaling).
Save heavy PNGs/JPEGs as highly compressed WEBP.
Define a box tuple (left, upper, right, lower) to slice.
Extract outline contours or sharp edges with ImageFilter.
Capture full screen, bounding box, or clipboard data.
Apply smooth radius-based Gaussian blur.
Overlay text using ImageDraw and a TrueType font.
Adjust brightness, contrast, color, or sharpness by factor.
Extract camera metadata embedded in JPEG photos.
Copy–paste solutions for the most common Pillow, OpenCV, and Computer Vision use cases.
Complete OCR pipeline: pre-process image with OpenCV, extract text bounding boxes with Tesseract OCR, and annotate bounding boxes and labels with Pillow ImageDraw.
Transform color images into 8-bit Grayscale (256 shades), 1-bit Dithered B&W, or Pure Binary (custom threshold point mapping) for OCR and barcode preprocessing.
Extract outline contours and sketch effects using Pillow's built-in ImageFilter.CONTOUR, FIND_EDGES, and EDGE_ENHANCE_MORE kernels.
Capture high-resolution screenshots, multi-monitor setups, cropped regions, or paste clipboard images directly into Pillow image memory.
Resize every image in a folder to 800×600 max bounding box, preserving aspect ratio. Ideal for pre-processing ML datasets or web asset pipelines.
Overlay semi-transparent text or logo watermarks on every image in a directory. Uses composite blending for professional results.
Read camera metadata from JPEG photos: GPS coordinates, make/model, ISO, shutter speed, and focal length — decoded to human-readable values.
Programmatically create Open Graph / Twitter card images. Draw a gradient background, overlay your title text, and export as optimized JPEG.
Use getbbox() to automatically detect non-white/non-black borders and crop the image to its real content region.
Convert an entire directory of PNG files to space-efficient WEBP format. Typically reduces file size by 25–34% without visible quality loss.
Create perfectly rounded circular avatar photos with alpha transparency masks. Ideal for web profiles, user avatars, and badge generators.
Add colored frame borders or uniform padding around an image using ImageOps.expand or fit images to fixed canvas dimensions with ImageOps.pad.
Stitch multiple image frames into a smooth, looping animated GIF with custom per-frame durations and loop controls.
Extract the top 5 dominant brand colors from any photo using Pillow's fast adaptive color quantization and histogram binning.
Seamlessly decode Apple iPhone .heic and .heif photos into Pillow images and batch convert them to web-ready JPEG or PNG formats.
Toggle the operations you need — copy a unified, ready-to-run processing pipeline.
Apply Pillow-equivalent effects instantly in your browser. Toggle filters and see the result in real time.
See how Pillow stacks up against other Python image processing libraries.
| Feature | Pillow ✅ | OpenCV | Wand (ImageMagick) | scikit-image | imageio |
|---|---|---|---|---|---|
| Pure Python API | ✅ Yes | ❌ C++ bindings | ❌ C bindings | ✅ Yes | ✅ Yes |
| Ease of Use | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| Format Support | 30+ formats | ~20 formats | 200+ formats | ~15 formats | ~20 formats |
| pip install size | ~3 MB | ~50 MB | ~30 MB | ~20 MB | ~1 MB |
| Drawing / Text | ✅ ImageDraw | ✅ cv2.putText | ✅ Drawing | ❌ Limited | ❌ None |
| Thumbnail Generation | ✅ One line | ⚠️ Manual | ✅ Yes | ⚠️ Manual | ⚠️ Manual |
| ML / NumPy Integration | ✅ np.array(img) | ✅ Native arrays | ⚠️ Limited | ✅ Native | ✅ Arrays |
| License | MIT (HPND) | Apache 2.0 | MIT | BSD | BSD |
| Best For | General purpose | Computer vision | Complex transforms | Scientific analysis | I/O only |
The top developer pain points when working with Pillow — with exact solutions.
Cause: Pillow is not installed in the current Python environment.
Fix: Install via pip. The package is called Pillow but imports as PIL.
Cause: The file extension doesn't match the actual format, or the file is corrupt/truncated.
Fix: Verify the actual format and pass the explicit format parameter.
Cause: Pillow's security limit blocks images larger than 178 million pixels by default to prevent DoS attacks.
Fix: Raise or disable the limit (only for trusted sources).
Cause: Camera stores orientation in EXIF tag but Pillow does not auto-rotate on open.
Fix: Use ImageOps.exif_transpose() to apply EXIF rotation automatically.
Cause: JPEG does not support transparency (alpha channel). The image has 4 channels (RGBA) instead of 3 (RGB).
Fix: Convert to RGB before saving as JPEG, or use PNG for transparency.
Cause: Image.ANTIALIAS was deprecated in Pillow 9.0.0 and completely removed in Pillow 10.0.0.
Fix: Replace Image.ANTIALIAS with Image.Resampling.LANCZOS (or Image.LANCZOS).
Cause: Pillow's native C extension was compiled against a different Python version or architecture (common on Apple Silicon M1/M2/M3).
Fix: Force-reinstall pre-built binary wheels cleanly.
Cause: Large images are loaded entirely into RAM before processing. A 100 MP TIFF can consume 1–2 GB uncompressed.
Fix: Use draft mode for loading, process in tiles, or downscale before processing.
Everything developers need to know about Pillow in Python.
Python Pillow is an open-source library that adds support for opening, manipulating, and saving many different image file formats. As the active fork of the original Python Imaging Library (PIL), Pillow is the foundational tool for image processing in Python — no complex C dependencies required for most operations.
PIL (Python Imaging Library) is the original, now-discontinued library that stopped supporting Python 3. Pillow is the actively maintained, drop-in compatible fork. It adds Python 3 support, security patches, new format support (WEBP, AVIF), and modern API improvements. You install Pillow but import it as PIL.
To install Pillow in an Anaconda or Conda environment, run: conda install -c conda-forge pillow (or conda install pillow). Pillow is also pre-packaged with default Anaconda distributions. In Anaconda Navigator, navigate to Environments, search for pillow, check the box, and click Apply.
There are three ways depending on your goal:
gray = img.convert('L')bw = img.convert('1')pure_bw = gray.point(lambda p: 255 if p > 128 else 0, mode='1')Combine OpenCV for preprocessing (grayscale, adaptive thresholding), Pillow for rendering annotations, and PyTesseract for text extraction:
1. Convert OpenCV BGR array to Pillow RGB: pil_img = Image.fromarray(cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB))
2. Run OCR: data = pytesseract.image_to_data(pil_img, output_type=pytesseract.Output.DICT)
3. Draw bounding boxes: draw = ImageDraw.Draw(pil_img); draw.rectangle([x, y, x+w, y+h], outline='red')
Run pip install Pillow. Even though the package is called Pillow, the import namespace is PIL for backward compatibility. Always use from PIL import Image in your code. If you're using a virtual environment, ensure it is activated first.
Use the ImageGrab module: from PIL import ImageGrab. Run screenshot = ImageGrab.grab() to take a full-screen screenshot, region = ImageGrab.grab(bbox=(0, 0, 800, 600)) for a specific bounding box, or clip = ImageGrab.grabclipboard() to get image data currently copied to your clipboard.
Call img.show() which saves a temporary copy and launches your operating system's default image viewer. Inside Jupyter Notebooks or Google Colab, simply write display(img) or type img as the last line of a cell to render inline.
No, standard Pillow requires C libraries (libjpeg, zlib, freetype) and several megabytes of RAM, which makes it incompatible with MicroPython boards like ESP32 or Raspberry Pi Pico. For MicroPython, use lightweight microcontroller framebuffer drivers such as framebuf or dedicated display drivers (ST7789, ILI9341).
Run in Python: import PIL; print(PIL.__version__). Or from your terminal: python -m PIL which will print the version and feature support matrix. You can also run pip show Pillow from the command line.
Pillow supports 30+ formats including JPEG, PNG, WEBP, GIF (animated), TIFF, BMP, ICO, EPS, PSD (Adobe Photoshop), PDF reading, PPM, PCX, and more. Some formats like AVIF require optional system libraries. Use Image.registered_extensions() to see all available formats in your installation.
Yes. You can convert between Pillow Images and NumPy arrays easily: arr = numpy.array(img) to convert to array, and img = Image.fromarray(arr) to convert back. This makes Pillow ideal as a preprocessing layer before feeding images into PyTorch, TensorFlow, OpenCV, or scikit-learn models.
Yes. Use img.seek(frame_number) to iterate through GIF frames. To create an animated GIF, open all frames as a list and use img.save('output.gif', save_all=True, append_images=[...], duration=100, loop=0). Pillow can also read animated WEBP and TIFF files.
Pillow is implemented in C via libjpeg-turbo, zlib, and other native codecs — making it significantly faster than pure Python alternatives. For high-throughput pipelines, use img.draft() for JPEG draft loading, process multiple images with concurrent.futures.ThreadPoolExecutor, and use img.thumbnail() instead of img.resize() to avoid unnecessary upscaling.
WEBP is fully supported for reading, writing, and animated WEBP files. AVIF support was added in Pillow 9.1.0 but requires libavif to be installed on your system. To check: PIL.features.check('avif'). Modern binary wheels on PyPI include WEBP support out of the box.
Pillow uses the HPND (Historical Permission Notice and Disclaimer) license — a permissive open-source license similar to MIT. It is completely free for commercial use, closed-source projects, and any application. No attribution is required in your product, though credit is always appreciated by the community.