Skip to content

WSILabs/wsitools

Repository files navigation

wsitools

CI License: Apache 2.0 Go Reference

A command-line toolkit for whole-slide imaging (WSI) files in digital pathology — inspect, edit, and convert slides across every major vendor format, from a single static binary with no runtime dependencies.

wsitools is built for pathology pipelines: edit associated images (like the label) without re-encoding the pyramid, transcode between containers and codecs, generate DeepZoom tiles for web viewers, downsample or crop slides, and check them for structural conformance.

Warning

Pre-1.0 — expect breaking changes. CLI flags, JSON fields, and output details may change between releases without deprecation. Pin a version and review CHANGELOG.md before upgrading.

What it does

  • Inspect — slide summary (levels, codecs, colorspace, metadata), per-IFD and per-tag dumps, content hashing, and structural validation. → info, dump-ifds, hash, validate
  • Extract a pixel region — save a rectangular region as a standalone PNG. → region
  • Extract an associated image — save the label, macro, thumbnail, or overview as a standalone PNG or JPEG. → extract
  • Edit — remove or replace an associated image. The pyramid tile bytes are copied verbatim (no decode/re-encode). → label|macro|thumbnail|overview remove|replace
  • Convert & transform — reshape a slide, streaming (no full-resolution raster in memory):
    • Re-container into another format — a lossless tile-copy when the source codec is compatible with the target. → convert --to {cog-wsi, svs, tiff, ome-tiff, dzi, szi, dicom, bif, ife}
    • Transcode the pyramid to a different codec. → convert --codec {jpeg, jpeg2000, jpegxl, avif, webp, htj2k}
    • Downsample to a lower magnification — during a convert, or in place (same container out). → convert --factor N / --target-mag M, or downsample
    • Crop a region — during a convert, or in place. → convert --rect X,Y,W,H, or crop
  • App info — report installed codecs and memory limits, or print the version. → doctor, version

Full per-command reference: docs/commands.md.

Note

Editing out the label is often a step in a de-identification workflow, but wsitools edits images — it does not, on its own, de-identify a slide. Other PHI may remain in slide metadata or in images you didn't remove. Removing an image deletes it from the output file; the rest of the slide is your responsibility.

Supported formats

Reads: Aperio SVS · Hamamatsu NDPI · Philips-TIFF · OME-TIFF · DICOM-WSI · Ventana/Roche BIF · Iris IFE · Leica SCN · generic tiled TIFF · COG-WSI

Writes: SVS · generic TIFF · OME-TIFF · COG-WSI · DICOM-WSI · DeepZoom (DZI) · SZI · BIF · IFE

Source format info region dump-ifds extract hash convert from convert to downsample / crop edit
SVS
Philips-TIFF
OME-TIFF ✓ (lossy)
BIF
generic-TIFF
NDPI ✓*
Leica SCN ✓*
COG-WSI
IFE
DICOM-WSI

✓* stripped source — decoded and re-encoded into reproducible JPEG tiles rather than bit-exact tile-copied. DICOM-WSI writing is experimental. Full matrix (including OME-OneFrame), convert targets, and per-format caveats: docs/formats.md.

Install

Prebuilt binaries (recommended)

Download the archive for your platform from the latest release, extract, and run wsitools. Every binary is statically linked and bundles all codecs (jpeg, jpeg2000, htj2k, jpegxl, avif, webp) — no toolchain or libraries needed. Verify with sha256sum -c SHA256SUMS.

Platform Asset
Linux x86-64 / arm64 wsitools-linux-{amd64,arm64}.tar.gz
macOS Apple Silicon / Intel wsitools-darwin-{arm64,amd64}.tar.gz
Windows x86-64 wsitools-windows-amd64.zip

macOS binaries are not yet signed or notarized. On first run, clear the quarantine flag with xattr -d com.apple.quarantine wsitools, or allow the binary in System Settings → Privacy & Security. Signing + notarization is planned — see the roadmap.

From source

With Go 1.26+ and the image codec libraries installed (JPEG is the only required one; the rest are optional):

go install github.com/wsilabs/wsitools/cmd/wsitools@latest

Step-by-step instructions for macOS, Linux, and Windows — including a JPEG-only minimal build and how to skip individual codecs — are in docs/INSTALL.md.

Quick start

# Slide summary (add --json for scripting)
wsitools info slide.svs

# Extract a pixel region as PNG
wsitools region --x 10000 --y 8000 --w 1024 --h 1024 --level 0 -o tile.png slide.svs

# Remove the label image — pyramid bytes untouched, no re-encode
wsitools label remove slide.svs            # → slide_relabeled.svs

# Re-container into COG-WSI (lossless tile-copy when the source codec fits the target)
wsitools convert --to cog-wsi -o slide.cog.tiff slide.svs

# Generate DeepZoom tiles for a web viewer (OpenSeadragon-compatible)
wsitools convert --to dzi -o slide.dzi slide.svs

# Crop a region into the same container (--lossless keeps L0 tiles byte-identical)
wsitools crop --rect 20000,15000,8192,8192 --lossless -o region.svs slide.svs

# Downsample a 40× slide to 20× (same container out)
wsitools downsample -o slide-20x.svs slide-40x.svs

More examples and every flag: docs/commands.md.

Documentation

Contributing & testing

make test   # unit + integration tests, race detector
make vet

Integration tests are fixture-gated by WSI_TOOLS_TESTDIR; CI pulls fixtures from wsilabs/wsi-fixtures on every push and PR.

License

Apache 2.0. See LICENSE.

About

Fast, cross-platform CLI toolkit for whole-slide imaging (WSI) in digital pathology — inspect, convert, downsample & extract regions from SVS, DICOM-WSI, BIF, NDPI, Philips-TIFF and more. DeepZoom (DZI/SZI) + Cloud-Optimized COG-WSI output. No OpenSlide dependency.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors