Start here: the most common Pillow problems
Each page reproduces the problem on Pillow 12.3.0, explains why it happens, and shows the fix with real output.
No module named 'PIL'
Installed Pillow but Python still cannot find it? It went into a different interpreter. How to check, and the fix for each setup.
Image has no attribute 'ANTIALIAS'
Removed in Pillow 10. Use Image.LANCZOS: the same filter, on every version.
cannot identify image file
Usually not an image at all: an HTML error page, an empty download or a HEIC photo. A script to tell which.
Resize and keep the aspect ratio
thumbnail, contain, cover, fit and pad compared side by side.
Add text to an image
Fonts, centring with anchors, outlines, translucent boxes, wrapping, emoji and non-Latin scripts.
Pillow and NumPy
Convert both ways without black images, wrong colours or Cannot handle this data type.
Build a Pillow script, then run it here
Tick the steps you need. The script updates as you go; Run executes it with real Pillow in your browser (Pyodide) on a sample photo. All 1,042 combinations of these options are run against Pillow 12.3.0 when the site is built.
from PIL import Image, ImageDraw, ImageEnhance, ImageOps
img = Image.open("phone.jpg")
# Fix phone-photo rotation (EXIF)
img = ImageOps.exif_transpose(img)
# Shrink to fit 800×800
img.thumbnail((800, 800), Image.LANCZOS)
# More contrast
img = ImageEnhance.Contrast(img).enhance(1.4)
# Add a caption
draw = ImageDraw.Draw(img)
draw.text((img.width // 2, img.height - 20), "Launch Pad 39B", fill="white", anchor="ms",
font_size=max(16, img.width // 18), stroke_width=2, stroke_fill="black")
img.save("result.jpg", quality=85, optimize=True)
print("saved result.jpg:", img.size, img.mode)
Every guide and error fix
Grouped by what you are trying to do. Guides explain a task; error pages start from the exact message you see.
Install and import errors
- GuideInstall Pillow (pip, venv, conda, Ubuntu, Mac, Windows)
- ErrorNo module named 'PIL'
- Errormodule 'PIL' has no attribute 'Image' (and other import mix-ups)
- Errorcannot import name '_imaging' / DLL load failed
- ErrorANTIALIAS removed
- Errortextsize / getsize removed
- Errormodule 'PIL.Image' has no attribute 'Resampling'
- Errorscipy.misc has no attribute imread / imresize
- ErrorDjango: Cannot use ImageField because Pillow is not installed
Open, save and convert
- GuideConvert image formats
- GuideReduce image file size
- Errorcannot identify image file
- Errorimage file is truncated
- Errorcannot write mode F / P / LA as JPEG
- ErrorDecompressionBombWarning / Error
- GuideOpen an image from a URL, bytes or base64
- GuideConvert an image to bytes or base64
- GuideGet image size, format and info
- GuideRead EXIF data (date taken, camera, GPS)
- GuideLoad and process all images in a folder
- GuideCreate, read and resize animated GIFs
- GuideRead and write TIFF files (multi-page, 16-bit, NumPy)
- GuideSave images as a (multi-page) PDF
- GuideDisplay an image (show, Jupyter, matplotlib, Tkinter)
Edit images
- GuideResize and keep aspect ratio
- GuideCrop an image (box, centre, circle, auto-crop)
- GuideRotate or flip an image (without cropping)
- GuideCombine images side by side or in a grid
- GuideSplit an image into tiles or a grid
- GuideAdd text to an image
- ErrorOSError: cannot open resource
- GuideDraw rectangles, circles, lines and polygons
- GuideOverlay a transparent PNG on an image
- GuideMake a white background transparent
- GuideConvert to greyscale or pure black and white
- GuideInvert image colours (negative), incl. RGBA
Pixels, NumPy, OpenCV and matplotlib
Browser tools that write Pillow code
Utilities that generate Pillow code from a live preview. They run locally in your browser; your images are not uploaded.
RGBA to JPEG fixer
Flatten transparency correctly and fix cannot write mode RGBA as JPEG.
1-bit threshold
Pure black and white with Otsu, Floyd–Steinberg or ordered dithering.
OpenCV / NumPy converter
Conversion code between Pillow, OpenCV, NumPy, Base64 and PyTorch.
Watermark generator
Text or logo watermarks with opacity, position and tiling.
ImageGrab builder
Screenshot and clipboard scripts, including Windows DPI scaling.
How the examples are tested
A script runs every example on Pillow 12.3.0 and Python 3.13 in a clean folder with the same sample files, and writes the output into the page. Continuous integration repeats this on Linux, Windows, macOS, and against the newest Pillow release, so pages show where behaviour differs between systems and are flagged when a release changes it. Examples that reproduce errors from older installs run on Pillow 9.0.1. The photos are public-domain NASA images. About the site and how we test.
Frequently asked questions
Is this the official Pillow website?
No. Pillow Python is an independent site. The official documentation is at pillow.readthedocs.io, and the project lives on GitHub. We are not affiliated with it.
What is the difference between PIL and Pillow?
PIL, the Python Imaging Library, stopped at version 1.1.7 in 2009 and never supported Python 3. Pillow is its maintained fork. You install pillow and import PIL: from PIL import Image.
How are the examples tested?
Every example is run by a script against a real Pillow installation before the page is published, and the output you see is what it printed. A scheduled job re-runs them on Linux, Windows and macOS and against each new Pillow release. More on how we test.
Which Pillow version do I have?
Run python -c "import PIL; print(PIL.__version__)" with the Python that runs your code. The install guide shows how to upgrade, and which Pillow supports which Python.
Do the Run buttons upload my code or images?
No. They run Pillow inside your browser with Pyodide (Python compiled to WebAssembly). Nothing is sent to a server; the first run downloads about 12 MB of Python and Pillow from a public CDN.