Skip to main content

libheif_binary

Prebuilt libheif and its codec libraries for Python packages that read and write HEIF and AVIF images. The package bundles native libraries and the heif-enc, heif-dec and heif-info commands, with a small Python API for loading libheif. It does not provide Python image objects or bindings to the full libheif API.

Supported platforms and Python versions

Requires Python 3.6 or newer and a wheel matching your operating system and architecture.

Platform Minimum system requirement Architectures Python
Linux, glibc (manylinux_2_28) glibc 2.28 x86_64, aarch64 3.6+
Linux, musl (musllinux_1_2) musl 1.2, including compatible Alpine Linux releases x86_64, aarch64 3.6+
macOS macOS 11 x86_64, arm64; combined universal2 wheel 3.6+

Windows is not supported.

Compatibility and test coverage are distinct:

Build Python versions checked by CI
Linux, glibc CPython 3.9, 3.14 and 3.14 free-threaded; PyPy interpreters included in the build image
Linux, musl CPython 3.9, 3.14 and 3.14 free-threaded
macOS, including both universal2 architectures CPython 3.12

Installation

Install the package:

pip install libheif_binary

The native libraries and CLI tools are bundled in the wheel. You do not need to install libheif or its codecs separately.

Python API

On Linux and macOS, preload the bundled library before importing a Python extension linked against libheif:

from libheif_binary import load_library

_libheif_handle = load_library()
from your_package import _libheif_cffi

Replace your_package._libheif_cffi with your extension module. Keep the returned ctypes.CDLL object alive until the extension has finished importing. The library is loaded with RTLD_GLOBAL so its symbols are available to linked extensions.

Command-line tools

Installation adds these commands to the Python environment:

Command Purpose
heif-enc Encode images as HEIF or AVIF
heif-dec Decode HEIF or AVIF images, including PNG and JPEG output
heif-info Inspect image metadata and container information

Use --help for the options supported by the bundled libheif version:

heif-enc --help
heif-dec --help
heif-info --help

By default, these commands start a Python wrapper that executes the native tool. To run them directly without starting Python, replace the wrappers in the installed environment with relative symlinks:

libheif-link-cli

This is optional and requires write access to the environment's scripts directory. Run it again after reinstalling or upgrading the package.

Building wheels

Run the following commands from the repository root. Wheels are saved in dist/. Dependency versions and source checksums are pinned in versions/*.env. The package version is <libheif version>.<packaging revision>.

Linux

With Docker running, build for glibc or musl:

make -C linux manylinux
make -C linux musllinux

To select an architecture, add ARCH=amd64 or ARCH=arm64:

make -C linux manylinux ARCH=arm64

Each build tests the installed wheel before exporting it.

macOS

Build with Python (3.12 tested) and the Xcode command-line tools:

make -C macos

The wheel targets the current architecture.

Testing

Run the unit tests from the repository root:

pytest tests -v

To test an installed wheel, run the smoke test:

python tests/smoke.py /path/to/example.heic

Use examples/example.heic from the pinned libheif source release.

Bundled libraries and licenses

The package includes libheif, x264, x265, libde265, libaom, libsharpyuv, libpng and libjpeg-turbo.

License and patent notices for bundled dependencies are included in the installed package's libheif_binary/licenses/ directory.

Metadata

Release files for libheif-binary 1.20.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for libheif-binary 1.20.2.1
File
libheif_binary-1.20.2.1-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
libheif_binary-1.20.2.1-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
libheif_binary-1.20.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
libheif_binary-1.20.2.1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64, Linux glibc 2.27+ ARM64 Details
libheif_binary-1.20.2.1-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details

Total release size: 40.4 MB

Release files / libheif_binary-1.20.2.1-py3-none-musllinux_1_2_x86_64.whl

Download URL libheif_binary-1.20.2.1-py3-none-musllinux_1_2_x86_64.whl
Size 7.4 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
a3e2ed8d33fe9d24042143ec05c6bc264964277003cfc3b857931b79aae765e2
BLAKE2b-256 checksum
How to use checksums
0dc6f97d9cc7e32e327116355c0147eeb28c00dd6581012b4af22d4a27bf6835
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / libheif_binary-1.20.2.1-py3-none-musllinux_1_2_aarch64.whl

Download URL libheif_binary-1.20.2.1-py3-none-musllinux_1_2_aarch64.whl
Size 8.4 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b7a2c92ee309815e30809a3eb6ac592eedd8621f461d2caec043ec7e7aa1709f
BLAKE2b-256 checksum
How to use checksums
f4b59c43e8e78fcd6100cf810336d5e35ac524f04dde5b8c5c46aedb16296c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / libheif_binary-1.20.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libheif_binary-1.20.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 6.4 MB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0623019bde0c9bdd0b780c8aaee2bd2aefa1167a7da2d45ccc4bedde41a78ba9
BLAKE2b-256 checksum
How to use checksums
5df69e8b170d6cd9e451d48b2b601065414474bc5a764cbd48e54ca8d6ba356a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / libheif_binary-1.20.2.1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL libheif_binary-1.20.2.1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 7.3 MB
Tags Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3adc8bb7de2b49087287077a774c233f6ecb0043305b6836c39fa8c99d7f5196
BLAKE2b-256 checksum
How to use checksums
f3479ceef0adf932186428c2a85a41912afe91d7418ce2ea5afa435d02c3c034
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / libheif_binary-1.20.2.1-py3-none-macosx_11_0_universal2.whl

Download URL libheif_binary-1.20.2.1-py3-none-macosx_11_0_universal2.whl
Size 11.0 MB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
554e14574acd9d4b8788148662812049a78fb99fdd60d2561584651a7b399557
BLAKE2b-256 checksum
How to use checksums
db37c6ae58114f24df4045d0ae857e3d0e7e94de8c4956963658413fc88e9ca9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page