Image File Formats
Pillow supports a wide variety of raster file formats. Over 30 different file formats can be identified and read by the library.
| Format | Read | Write | Notes |
|---|---|---|---|
| JPEG / JPG | ✅ | ✅ | Lossy. No alpha. Most common photo format. |
| PNG | ✅ | ✅ | Lossless with alpha. Best for UI / screenshots. |
| GIF | ✅ | ✅ | Animated. 256-colour palette only. |
| WebP | ✅ | ✅ | Lossy/lossless, animated. Best web compression. |
| TIFF / TIF | ✅ | ✅ | Multi-page, raw, high-quality. Used in print/medical. |
| BMP | ✅ | ✅ | Uncompressed raster. Windows bitmap. |
| ICO | ✅ | ✅ | Windows icon format with multiple sizes. |
| ❌ | ✅ | Can write images as PDF pages. Read not supported. | |
| EPS / PS | ✅ * | ✅ | Requires Ghostscript for reading. |
| SVG | ✅ * | ❌ | Read via Wand or extra plugins. Pillow core = no. |
| HEIC / HEIF | ✅ * | ✅ * | Requires pillow-heif plugin package. |
| PPM / PBM / PGM | ✅ | ✅ | Portable bitmap formats (Unix legacy). |
| TGA | ✅ | ✅ | Targa format. Common in 3D/game pipelines. |
| PCX | ✅ | ✅ | ZSoft PC Paintbrush. |
| SGI / RGB | ✅ | ✅ | Silicon Graphics Image format. |
| DDS | ✅ | ✅ | DirectDraw Surface — used in DirectX games. |
| AVIF | ✅ * | ✅ * | Requires pillow-avif-plugin. |
| XBM | ✅ | ✅ | X11 bitmap format. |
| SPIDER | ✅ | ✅ | SPIDER image format (data visualization). |
| IM | ✅ | ✅ | LabEye IM format. |
* = Requires optional dependency or plugin
JPEG
JPEG is the most common format for photographs. It uses lossy compression that significantly reduces file size but cannot store alpha transparency. The JPEG/JFIF format supports RGB, L, and CMYK modes.
OSError. Always convert("RGB") first.
PNG
PNG is a lossless format supporting transparency. It supports modes 1, L, P, RGB, and RGBA. PNG files contain a series of chunks — Pillow exposes most of these via the info dictionary.
GIF
GIF supports animation and transparency but is limited to 256 colours per frame. Pillow reads and writes GIF files, including animated ones.
WebP
WebP provides both lossy and lossless compression with support for transparency and animation. It generally achieves 25-35% smaller files than JPEG at the same visual quality, making it the recommended format for modern web images.
TIFF
TIFF is a flexible raster format widely used in print, medical imaging, and GIS industries. Pillow supports multi-page TIFF and a variety of compression options.
BMP
BMP is the native Windows bitmap format. It stores uncompressed image data and supports a wide range of pixel depths (1, 4, 8, 16, 24, 32 bit). Modes: 1, L, P, RGB. Writing is limited to these modes.
ICO (Windows Icon)
ICO files contain multiple image sizes in a single file. Pillow can read and write ICO files, embedding multiple sizes.
Pillow can save images as single-page or multi-page PDF documents. Reading PDFs is not supported in Pillow core — use PyPDF2 or mupdf for that.
EPS / PS (PostScript)
Pillow can write EPS format and can read it if Ghostscript is installed. Ghostscript must be on the system path for rasterization of EPS to work.
SVG (Read-Only via Plugins)
Pillow's core does not support SVG. To render SVG files with Pillow, use a third-party library such as cairosvg, svglib, or Wand (ImageMagick binding) to first convert the SVG to PNG, then open it in Pillow.
HEIC / HEIF (via plugin)
HEIC is Apple's default photo format since iOS 11. Pillow supports it through the pillow-heif plugin.
Other Supported Formats
| Format | Extension | Notes |
|---|---|---|
| PPM / PBM / PGM / PNM | .ppm .pbm .pgm .pnm | Portable Any Map. Simple uncompressed formats. |
| TGA / TARGA | .tga .vda .icb .vst | Targa image. No magic number — extension-based detection. |
| PCX | .pcx | ZSoft PC Paintbrush. Modes: 1, L, P, RGB. |
| SGI | .sgi .rgb .bw | Silicon Graphics native format. |
| DDS | .dds | DirectDraw Surface. Used in DirectX/OpenGL games. |
| IM | .im | LabEye IM format. |
| XBM | .xbm | X11 bitmap. Mode: 1 only. |
| XPM | .xpm | X11 colour pixmap. Read only. |
| FITS | .fits .fit .fts | NASA Flexible Image Transport System. Scientific imagery. |
| JPEG 2000 | .jp2 .j2k .jpf .j2c | Wavelet compression JPEG successor. Modes: L, RGB, RGBA. |
| PSD | .psd | Adobe Photoshop. Read only, flattened. |
| DCX | .dcx | Intel FAX format (multipage PCX). |
| MSP | .msp | Windows 1.x/2.x Paint. Mode: 1 only. |