Skip to main content

pyheif

Python 3.6+ interface to libheif library using CFFI

Note: currently only reading is supported.

Installation

Simple installation - Linux (installs manylinux2014 wheel, doesn't work with Alpine)

pip install --upgrade pip
pip install pyheif

Installing from source - MacOS

brew install libffi libheif
pip install git+https://github.com/carsales/pyheif.git

Installing from source - Linux

apt install libffi libheif-dev libde265-dev

or

yum install libffi libheif-devel libde265-devel

then

pip install git+https://github.com/carsales/pyheif.git

Installing from source - Windows

Sorry, not going to happen!

Usage

Read the primary image of a HEIF encoded file

The pyheif.read(path_or_bytes) function can be used to read the primary image of a HEIF encoded file. It can be passed any of the following:

  • A string path to a file on disk
  • A pathlib.Path path object
  • A Python bytes or bytearray object containing HEIF content
  • A file-like object with a .read() method that returns bytes

It returns a HeifImage object.

import pyheif

# Using a file path:
heif_file = pyheif.read("IMG_7424.HEIC")
# Or using bytes directly:
heif_file = pyheif.read(open("IMG_7424.HEIC", "rb").read())

Converting to a Pillow Image object

If your HEIF file contains an image that you would like to manipulate, you can do so using the Pillow Python library. You can convert a HeifImage to a Pillow image like so:

from PIL import Image
import pyheif

heif_file = pyheif.read("IMG_7424.HEIC")
image = Image.frombytes(
    heif_file.mode, 
    heif_file.size, 
    heif_file.data,
    "raw",
    heif_file.mode,
    heif_file.stride,
    )

Note: the mode property is passed twice - once to the mode argument of the frombytes method, and again to the mode argument of the raw decoder.

You can now use any Pillow method to manipulate the file. Here's how to convert it to JPEG:

image.save("IMG_7424.jpg", "JPEG")

Read the entire container within the HEIF file

The pyheif.open_container(path_or_bytes) function can be used to read the HEIF container from a HEIF encoded file. It takes the same parameter as pyheif.read()

It returns a HeifContainer object.

Objects

The HeifImage object

The HeifImage has the following properties:

  • mode - the image mode, e.g. "RGB" or "RGBA"
  • size - the size of the image as a (width, height) tuple of integers
  • data - the raw decoded file data, as bytes
  • metadata - a list of metadata dictionaries
  • color_profile - a color profile dictionary
  • stride - the number of bytes in a row of decoded file data
  • bit_depth - the number of bits in each component of a pixel

The UndecodedHeifImage object

This is a HEIF image that has not been decoded. Calling the UndecodedHeifImage.load() method will load the data and the object will become a HeifImage

The HeifContainer object

The HeifContainer has the following properties:

  • primary_image - the HeifTopLevelImage object of the primary image in the file.
  • top_level_images - a list of all HeifTopLevelImage objects in the file.

The HeifTopLevelImage object

The HeifTopLevelImage has the following properties:

  • id - the id of the image
  • image - the UndecodedHeifImage or HeifImage object of the image
  • is_primary - is this the primary image in the container
  • depth_image - the HeifDepthImage if there is one
  • auxiliary_images - a list of HeifAuxiliaryImage objects

The HeifDepthImage object

The HeifDepthImage has the following properties:

  • id - the id of the image
  • image - the UndecodedHeifImage or HeifImage object of the image

The HeifAuxiliaryImage object

The HeifAuxiliaryImage has the following properties:

  • id - the id of the image
  • image - the UndecodedHeifImage or HeifImage object of the image
  • type - a string indicating the type of auxiliary image

Release files for pyheif 0.8.0

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

Source distribution (sdist)

Source distribution for pyheif 0.8.0
File Size Uploaded
pyheif-0.8.0.tar.gz 20.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyheif 0.8.0
File
pyheif-0.8.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.10 PyPy 3.10 7.3 Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl PyPy 3.10 PyPy 3.10 7.3 Linux glibc 2.17+ ARM64 Details
pyheif-0.8.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.9 PyPy 3.9 7.3 Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl PyPy 3.9 PyPy 3.9 7.3 Linux glibc 2.17+ ARM64 Details
pyheif-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
pyheif-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
pyheif-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
pyheif-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ ARM64 Details
pyheif-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ ARM64 Details
pyheif-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
pyheif-0.8.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ ARM64 Details

Total release size: 85.1 MB

Release files / pyheif-0.8.0.tar.gz

Download URL pyheif-0.8.0.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e9b4c11ebad482fc25a0804ce295b44b660cbf7829a228f56b071f325f9e0de4
BLAKE2b-256 checksum
How to use checksums
ec11d63f215d8c9c416409e2d665bf7594a8886780629296b4f0d35857561c9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.1

Release files / pyheif-0.8.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.2 MB
Tags Linux glibc 2.17+ x86-64 PyPy 3.10 PyPy 3.10 7.3
SHA-256 checksum
How to use checksums
ef3255c5dd9062f38fea0f4cb41f3192616307252db448a2064f8bce31640112
BLAKE2b-256 checksum
How to use checksums
15b56cbe1e0bcd0db171e57a838fbf611d937ce120b87a045b6d4a868d85f394
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.3 MB
Tags Linux glibc 2.17+ ARM64 PyPy 3.10 PyPy 3.10 7.3
SHA-256 checksum
How to use checksums
c9f1c8e3158b98fc82b3833e7358f6ca0ef9d50fa93d20993925917e9189bbc6
BLAKE2b-256 checksum
How to use checksums
35175a5a70da5b6dd52937e38259e65180414e4c5625717b139a6f7aa30a79a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.2 MB
Tags Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
b896eebf440ea826893a253c8f8a5bbd245f96a1613858d7c4ec310420ab9cec
BLAKE2b-256 checksum
How to use checksums
4c0dcee50b45e7360226e6c66f9b65fbb3a354ab7a35dc54e335d1cae9f03dcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.3 MB
Tags Linux glibc 2.17+ ARM64 PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
39214792559eab90814f9551540156550619fc6f8f0d794091488563577da5ca
BLAKE2b-256 checksum
How to use checksums
8d97a180a87119f81f06d032a0530f4636e1c1e75d9589c8c6b915d80cb0743f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.3 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f98f4b1d37705418d77ef42a8ebf95b510bb3e0a9a2d9f0824f6eeb751c9e7f6
BLAKE2b-256 checksum
How to use checksums
87c41d0e82766657b3839993ffe411807a08623ff9affd7275533afea3cb377e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
ac5ec62a90c4f9f96125aaebd6ac994b95895ace4427ecf34752951e1d34be96
BLAKE2b-256 checksum
How to use checksums
fc4907d1c047e52fd4de1474759e202b2fd7ac99e945db0ce149af2f85be7625
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.3 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
4c8723ab28ca9f42e0f25a29008673654e062edb95b26dbfa3e397e6cc3d56b8
BLAKE2b-256 checksum
How to use checksums
6fa92514a4d53ed5712bdda42281d0b3b0f652ccd35ba08b66039510592cf67e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
01c94cc524446d6e23a2726d4cec94c764b277466cbeca4d95e083390b09ad34
BLAKE2b-256 checksum
How to use checksums
62e752450ce4cf5e682ea8950f86725dffad461ca8b24c9215ac76d61e2d8392
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.3 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e93ff599eba671718e9dcab2dcd4efdbcbdbe4bcd31bd9477026e2ffc39125b2
BLAKE2b-256 checksum
How to use checksums
d29aec37ceaf6b93a23c33c6080a7ac2570148d0a51fc4db733dc2ea735526de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
6a9df316c695c7a4588633486c5f93508474653488dbcb8c968dc0c611875106
BLAKE2b-256 checksum
How to use checksums
529840d97d38454f6708db7b819b8c206e206e4730183860b3a3be56fa44cdab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.3 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f6e08cdd85f638e134cbd94006631d8e5263002a3f8c4f44b1f94626fb0cf4f3
BLAKE2b-256 checksum
How to use checksums
1142b0fac6f16c96e54039bc66578aa559a06d0c24c413e9f061dc2d1ac1637e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
adba452e061b4b1edf57ad561daf69f3e67de4be42088885685ef4e6a8dd9baf
BLAKE2b-256 checksum
How to use checksums
25ed108eabdcbd8a12ac31b4979dd9a9bfd8342590db27037ecba3ce5a773276
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.3 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
272d08f3308dcac1ad12b100f0d433f28e4f6e2aef0c28feee1d4b2bbf7e8f81
BLAKE2b-256 checksum
How to use checksums
391b1519742ac0ac5e1c43b1444bbdae6de15054443d501eadb83e1749a03bf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
037fcfb4facb5160c6c874824b4fe4dab7855653a3114ed08c8273209d7e5cf5
BLAKE2b-256 checksum
How to use checksums
2bb4947f2bc3800fcbead2e264b9ceaa41b6bb9eb85e7458847fa9aec6877f50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyheif-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ac63592bca147d74277664e5f46ae80fd721da1ab6650177d763201a43638f75
BLAKE2b-256 checksum
How to use checksums
0e20d4221a5e85f9ae4913ca265d4549e43279b1bd38e2ba4c5d847898b611f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / pyheif-0.8.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyheif-0.8.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
4e4aa21e9bd92dbca7f3d281a4176611ccbcbb13990adcc74ccf4503498d2947
BLAKE2b-256 checksum
How to use checksums
68361d15e207f0f2903c86c93ac03d1c33bcc62d8e546ade3836d0704a5ca47e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release history Release notifications | RSS feed

This release

0.8.0 This release

17 release files

0.7.1

9 release files

0.7.0

8 release files

0.6.1

8 release files

0.6.0

8 release files

0.5.2

6 release files

0.5.1

5 release files

0.5.0

3 release files

0.4

4 release files

0.3.3

4 release files

0.3.2

5 release files

0.3.1

5 release files

0.3

4 release files

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