The imagecodecs package provides various block-oriented, in-memory buffer transformation, compression, and decompression functions for use in the tifffile, czifile, and other Python imaging modules. Decode and/or encode functions are currently implemented for Zlib DEFLATE, ZStandard, Blosc, LZMA, BZ2, LZ4, LZW, LZF, PNG, WebP, JPEG 8-bit, JPEG 12-bit, JPEG SOF=0xC3, JPEG 2000, JPEG XR, PackBits, Packed Integers, Delta, XOR Delta, Floating Point Predictor, and Bitorder reversal.

aec, bz2, gif, image, jpeg, jpeg2000, jpegls, jpegxr, lerc, lz4, lzf, lzma, lzw, packbits, png, python, tiff, webp, zfp
conda install -c anaconda imagecodecs


Image transformation, compression, and decompression codecs

Imagecodecs is a Python library that provides block-oriented, in-memory buffer transformation, compression, and decompression functions for use in the tifffile, czifile, and other scientific image input/output modules.

Decode and/or encode functions are implemented for Zlib (DEFLATE), ZStandard (ZSTD), Blosc, Brotli, Snappy, LZMA, BZ2, LZ4, LZW, LZF, ZFP, AEC, LERC, NPY, PNG, GIF, TIFF, WebP, JPEG 8-bit, JPEG 12-bit, JPEG SOF3 (LJPEG), JPEG 2000, JPEG LS, JPEG XR, JPEG XL, PackBits, Packed Integers, Delta, XOR Delta, Floating Point Predictor, Bitorder reversal, and Bitshuffle.

Author: Christoph Gohlke
Organization: Laboratory for Fluorescence Dynamics. University of California, Irvine
License: BSD 3-Clause
Version: 2020.5.30


This release has been tested with the following requirements and dependencies (other versions may work):

Required Python packages for testing (other versions may work):


The API is not stable yet and might change between revisions.

Works on little-endian platforms only.

Python 32-bit versions are deprecated. Python 2.7 and 3.5 are no longer supported.

The latest Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 is required on Windows.

Refer to the imagecodecs/licenses folder for 3rd party library licenses.

This software is based in part on the work of the Independent JPEG Group.

This software includes modified versions of dcm2niix's jpg_0XC3.cpp and OpenJPEG's color.c.

Build instructions and wheels for manylinux and macOS courtesy of Grzegorz Bokota.

Update pip and setuptools to the latest version before installing imagecodecs:

python -m pip install --upgrade pip setuptools

Install imagecodecs using precompiled wheels:

python -m pip install --upgrade imagecodecs

Install the requirements for building imagecodecs from source code on latest Ubuntu Linux distributions:

sudo apt-get install build-essential python3-dev cython3 python3-setuptools python3-pip python3-wheel python3-numpy python3-pytest python3-blosc python3-brotli python3-snappy python3-lz4 libz-dev libblosc-dev liblzma-dev liblz4-dev libzstd-dev libpng-dev libwebp-dev libbz2-dev libopenjp2-7-dev libjpeg-dev libjxr-dev liblcms2-dev libcharls-dev libaec-dev libbrotli-dev libsnappy-dev libzopfli-dev libgif-dev libtiff-dev

Use the --lite build option to only build extensions without 3rd-party dependencies. Use the --skip-extension build options to skip building specific extensions, e.g.:

python -m pip install imagecodecs --global-option="build_ext" --global-option="--skip-bitshuffle"

The jpeg12, jpegls, jpegxl, zfp, and lerc extensions are disabled by default when building from source.

To modify other build settings such as library names and compiler arguments, provide a imagecodecs_distributor_setup.customize_build function, which will be imported and executed during setup. See for examples.

Other Python packages and C libraries providing imaging or compression codecs:


Pass 4563 tests. Add LERC codec via ESRI's lerc library. Enable building JPEG extensions with libjpeg >= 8. Enable distributors to modify build settings.
Fix segfault when decoding corrupted LZW segments. Work around Cython raises AttributeError when using incompatible numpy. Raise ValueError if in-place decoding is not possible (except floatpred).
Add GIF codec via giflib. Add TIFF decoder via libtiff (WIP). Add codec_check functions (WIP). Fix formatting libjpeg error messages. Use xfail in tests. Load extensions on demand on Python >= 3.7. Add build options to skip building specific extensions. Split imagecodecs extension into individual extensions. Move shared code into shared extension. Rename imagecodecs_lite extension and imagecodecs C library to 'imcd'. Remove support for Python 2.7 and 3.5.
Fix decoding of indexed PNG with transparency. Last version to support Python 2.7 and 3.5.
Add Zopfli codec. Add Snappy codec. Rename j2k codec to jpeg2k. Rename jxr codec to jpegxr. Use Debian's jxrlib. Support pathlib and binary streams in imread and imwrite. Move external C declarations to pxd files. Move shared code to pxi file. Update copyright notices.
Add version functions. Add Brotli codec (WIP). Add optional JPEG XL codec via Brunsli repacker (WIP).
Sync with imagecodecs-lite.
Add AEC codec via libaec (WIP). Do not require scikit-image for testing. Require CharLS 2.1.
Add bitshuffle codec. Fix formatting of unknown error numbers. Fix test failures with official python-lzf.
Rebuild with updated dependencies.
Add optional YCbCr chroma subsampling to JPEG encoder. Add default reversible mode to ZFP encoder. Add imread and imwrite helper functions.
Fix setup requirements.
Move codecs without 3rd-party C library dependencies to imagecodecs_lite.
Rebuild with updated dependencies.
Add more pixel formats to JPEG XR codec. Add JPEG XR encoder.
Add optional ZFP codec via zfp library (WIP). Add numpy NPY and NPZ codecs. Fix some static codechecker errors.

Refer to the CHANGES file for older revisions.