Image Processing

Pillow makes thumbnails, crops, and format conversions, and scikit-image analyzes images for science. pyvips streams large images instead of loading them whole.

How to choose:

  • Thumbnails, crops, and format conversion: Pillow
  • Scientific image analysis on NumPy arrays: scikit-image
  • Large images or batch jobs short on memory: pyvips
  • Removing photo backgrounds: rembg
  • ImageMagick from Python: Wand
  • QR codes: qrcode
  • Linear barcodes like EAN-13 and Code 128: python-barcode
  • Resizing and cropping on request over HTTP: thumbor

Listed in editorial order, grouped by use case. Click a column header to re-sort the whole list.

Press / to search. Tags open their category. Click a row for details.

Search and filter

Results

Row number Tags

General 5 projects

Pillow is the friendly PIL fork.
A Python library for (scientific) image processing.
A tool to remove image backgrounds.
danielgatis/github.com/danielgatis/rembg /25,947 stars /
Python bindings for MagickWand, C API for ImageMagick.
emcconville/github.com/emcconville/wand /1,483 stars /
A binding for libvips, a fast image processing library with low memory needs.
libvips/github.com/libvips/pyvips /816 stars /

Barcodes and QR Codes 2 projects

A pure Python QR Code generator.
Create barcodes in Python with no extra dependencies.

Image Serving 1 project

A smart imaging service. It enables on-demand crop, resizing and flipping of images.
thumbor/github.com/thumbor/thumbor /10,536 stars /

Image Processing guide

Pillow

Start with Pillow for everyday work. Its docs pitch it for batch jobs that create thumbnails and convert between file formats. Move to scikit-image when you need to analyze what an image shows, or to pyvips when images get big enough that memory runs short. Shrink images with thumbnail(), which keeps the aspect ratio for you.

scikit-image

Pick scikit-image when you analyze images for research rather than edit them. The project serves scientific applications over consumer image editing, and works on plain NumPy arrays instead of fancy image objects. Convert between data types with img_as_float() and its siblings, never astype(), which breaks the value ranges its functions expect.

pyvips

Pick pyvips when images are large or a batch job runs short of memory. You build a pipeline of operations, and pyvips streams the image through it a section at a time, so it doesn't need to keep the whole image in memory. For thumbnails, call pyvips.Image.thumbnail() on the file, which loads and resizes in one step.

rembg

rembg is the one listed tool that removes image backgrounds, and it runs as a command-line tool, a Python library, or an HTTP server. For a batch, create one session with new_session() and pass it to every remove() call. Each model's weights carry their own license, apart from rembg's, so check it before commercial use.

Wand

Pick Wand when you want ImageMagick's features from Python through a Pythonic, modern interface. Wand only binds to ImageMagick, so install ImageMagick on the system as well.

qrcode and python-barcode

qrcode makes QR codes and python-barcode makes linear barcodes like EAN-13 and Code 128, so pick by the symbol you need. In qrcode, qrcode.make() covers the quick case, and the QRCode class sets size, border, and error correction. python-barcode's docs recommend SVG unless your target can't show it, since vectors scale better.

thumbor

Run thumbor when your site needs images resized and cropped on request from a URL, not generated ahead of time. Its smart detection finds faces and other important points for better crops. Before going live, sign URLs with SECURITY_KEY so nobody can tamper with them, and turn off ALLOW_UNSAFE_URL, which its docs warn opens thumbor to DDoS attacks.

Handling uploaded images

Treat every uploaded image as untrusted: Pillow's security guide names parsing untrusted image data as Pillow's main attack surface, and puts sandboxed worker processes first in its recommendations. Wand's docs say to never run it inside an HTTP service, only in a background worker. With pyvips, set VIPS_BLOCK_UNTRUSTED and stick to the loaders libvips has tested for security.

Know a project that belongs here?

Tell us what it does and why it stands out.