openslide/openslide-python

Python bindings to OpenSlide

What it solves

Whole-slide images (virtual slides) used in digital pathology are extremely large—often tens of gigabytes when uncompressed—and are typically stored at multiple resolutions. Standard imaging tools and libraries assume that entire images can fit comfortably in memory, so they fail to handle these files. OpenSlide Python gives a simple way to read just the small portion of image data you need, at the resolution closest to a desired zoom level, without loading the whole image.

How it works

OpenSlide Python is a Python interface to the OpenSlide C library. The C library provides the core reading and decoding logic for a wide range of whole-slide formats. The Python wrapper exposes this functionality through a clean API that you can use directly in your Python code. To use it, you need to install both the openslide-python package (the Python interface) and openslide-bin (which bundles the underlying OpenSlide library and its dependencies). Once installed, you can open supported slide files and access tiles or regions at various zoom levels.

Who it’s for

This library is aimed at developers and researchers working with digital pathology images—for example, building tools for viewing, analyzing, or processing whole-slide scans. It is especially useful for anyone who needs to read large, multi‑resolution slide files programmatically in Python without writing low‑level C code.

Highlights

  • Supports a broad range of whole-slide formats, including Aperio (.svs), Hamamatsu (.ndpi), Leica (.scn), Philips (.tiff), and generic tiled TIFF.
  • Provides a simple Python API that abstracts away the complexity of handling multi‑resolution, multi‑gigabyte images.
  • Lets you read small regions at the resolution closest to a desired zoom level, so you avoid loading the entire file into memory.
  • Requires only Python ≥ 3.10, OpenSlide ≥ 3.4.0, and Pillow, and can be installed easily from PyPI.

Related

  • Project
  • Project
  • Project
  • Project