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.

Package version

The package version is <libheif version>.<packaging revision>. See Revisions for packaging changes.

Python API

get_version_str() returns the bundled libheif version as a string, such as "1.17.6". get_version() returns it as an integer tuple, such as (1, 17, 6).

get_build_config() returns cffi compiler and linker arguments for the bundled headers and library:

from cffi import FFI
from libheif_binary import get_build_config

ffi = FFI()
ffi.set_source("_libheif", "#include <libheif/heif.h>", **get_build_config())

get_executable(name) returns an absolute path to heif-enc, heif-dec or heif-info.

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.

Updating dependencies

With Bash, curl, jq, authenticated GitHub CLI (gh), tar and shasum installed, check for stable releases and update the pinned versions and SHA-256 sums:

make -C versions

To check just one library, run, for example, make -C versions libheif.env. x264 is excluded from the default updates; update it explicitly with make -C versions x264.env.

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

Install development dependencies and run lint and unit tests from the repository root:

pip install --group dev
make check

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, x265, libde265, libaom, libsharpyuv, libpng and libjpeg-turbo.

Format Encoders Decoders
HEVC / HEIC x265 libde265
AV1 / AVIF libaom libaom
JPEG in HEIF libjpeg-turbo libjpeg-turbo

HEIC and AVIF support 8-, 10- and 12-bit encoding and decoding.

See ROADMAP.md for the proposed extended bundle.

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

Revisions

Revision 4

  • Disable x264.
  • Enable JPEG-in-HEIF encoding and decoding with libjpeg-turbo.
  • Enable 10- and 12-bit encoding for x265.

Revision 3

  • Update libaom from 3.15.1 to 3.15.2.
  • Preserve ordinary symbol tables in all built libraries while excluding debug information.
  • Restore compiler optimization for SharpYUV.
  • Use shared SharpYUV libraries.
  • Bundle source-built libpng 1.6.59 and libjpeg-turbo 3.2.0 on Linux.

Revision 2

  • Bundle libheif headers with the plugin directory cleared.
  • Add get_build_config() and expose bundled executable paths.

Revision 1

  • Include README in wheels.

Revision 0

  • Bundle libheif, CLI tools, and codec libraries: x264 build 165 (commit 0480cb05fa18), x265 4.2, libde265 1.1.3, libaom 3.15.1, and SharpYUV from libwebp 1.6.0.
  • Provide library preloading and libheif-link-cli for replacing CLI wrappers with symlinks.

Metadata

Release files for libheif-binary 1.23.7.4

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.23.7.4
File Actions
libheif_binary-1.23.7.4-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for libheif_binary-1.23.7.4-py3-none-musllinux_1_2_x86_64.whl
libheif_binary-1.23.7.4-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for libheif_binary-1.23.7.4-py3-none-musllinux_1_2_aarch64.whl
libheif_binary-1.23.7.4-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 for libheif_binary-1.23.7.4-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
libheif_binary-1.23.7.4-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 for libheif_binary-1.23.7.4-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
libheif_binary-1.23.7.4-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details for libheif_binary-1.23.7.4-py3-none-macosx_11_0_universal2.whl
libheif_binary-1.23.7.4-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for libheif_binary-1.23.7.4-py3-none-macosx_11_0_arm64.whl

Total release size: 67.0 MB

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

Download URL libheif_binary-1.23.7.4-py3-none-musllinux_1_2_x86_64.whl
Size 10.6 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c81a31aa601e6e20962fefa3729797d7b05e29aaf4d254b7e2e0888989713489
BLAKE2b-256 checksum
How to use checksums
b7a4102aa5533ef6c9ef7900f508f6a6c7939ecfcdfd558f79d1c7f85c6da7a1
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.23.7.4-py3-none-musllinux_1_2_aarch64.whl

Download URL libheif_binary-1.23.7.4-py3-none-musllinux_1_2_aarch64.whl
Size 12.0 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
21fb4d10735c932aa4e331e43fbd9bf092f514c130ee297a5514003d6c6436b1
BLAKE2b-256 checksum
How to use checksums
fd3e3fa18b5b82c2142c3c2c3ce8f35a019020904cee4b204773635165d9f45c
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.23.7.4-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libheif_binary-1.23.7.4-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.6 MB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
d53569e50ac95a9f00436c3702bae0a3e150c35c45552542995f47f3bbe63382
BLAKE2b-256 checksum
How to use checksums
84c86f155f60f90edcdc74f63bd7f13762257a5db8796466eb17ada1907f9fd2
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.23.7.4-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL libheif_binary-1.23.7.4-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 11.0 MB
Tags Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
742aad3ec447c3a841eb404b699686f74cdd96a451d32b3986c89e23a39a1b0a
BLAKE2b-256 checksum
How to use checksums
70e6259b5ef295bae179317bd9ea045c7720f5b0281e555772ec5897a45174d1
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.23.7.4-py3-none-macosx_11_0_universal2.whl

Download URL libheif_binary-1.23.7.4-py3-none-macosx_11_0_universal2.whl
Size 16.0 MB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
e783ce53e4d0bf2a2cc047791899112b3d17ae0815c1e8700348814b062575a1
BLAKE2b-256 checksum
How to use checksums
90c22af39745ee17d430e785a18bf09147ce5a47b600f5403c56c38a5be69f69
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.23.7.4-py3-none-macosx_11_0_arm64.whl

Download URL libheif_binary-1.23.7.4-py3-none-macosx_11_0_arm64.whl
Size 7.8 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ccae82df74c4336b0531272803a2e014998c9bcbdf9a823f491ece2169465204
BLAKE2b-256 checksum
How to use checksums
622d8ab762c2ebe9ac116398cca65493a43f60de1a6fd93af31f41518c919e70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for libheif-binary 1.23.7.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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