bigcat88/pillow_heif

Python library for working with HEIF images and plugin for Pillow.

Python

306

1,026 commits

updated Oct 11, 2026

See the code

README

pillow-heif

Test Wheels docs codecov

PythonVersion impl pypi Downloads Downloads

Mac OS Windows Linux Alpine Linux Raspberry Pi

Python bindings to libheif for working with HEIF images and plugin for Pillow.

Features:

  • Decoding of 8, 10, 12 bit HEIC files.
  • Encoding of 8, 10, 12 bit HEIC files.
  • EXIF, XMP, IPTC read & write support.
  • Support of multiple images in one file and a PrimaryImage attribute.
  • Adding & removing thumbnails.
  • Grid(tiled) image encoding, like Apple devices do.
  • Reading of Depth Images.
  • (beta) Reading of Auxiliary Images by johncf
  • Adding HEIF support to Pillow in one line of code as a plugin.

Note: The light version pi-heif of this project is discontinued, 1.4.0 is its final release.

Install

python3 -m pip install -U pip
python3 -m pip install pillow-heif

Example of use as a Pillow plugin

from PIL import Image
from pillow_heif import register_heif_opener

register_heif_opener()

im = Image.open("image.heic")  # do whatever need with a Pillow image
im = im.rotate(13)
im.save(f"rotated_image.heic", quality=90)

16 bit PNG to 10 bit HEIF using OpenCV

import cv2
import pillow_heif

cv_img = cv2.imread("16bit_with_alpha.png", cv2.IMREAD_UNCHANGED)
heif_file = pillow_heif.from_bytes(
    mode="BGRA;16",
    size=(cv_img.shape[1], cv_img.shape[0]),
    data=bytes(cv_img)
)
heif_file.save("RGBA_10bit.heic", quality=-1)

8/10/12 bit HEIF to 8/16 bit PNG using OpenCV

import numpy as np
import cv2
import pillow_heif

heif_file = pillow_heif.open_heif("image.heic", convert_hdr_to_8bit=False, bgr_mode=True)
np_array = np.asarray(heif_file)
cv2.imwrite("image.png", np_array)

Accessing decoded image data

import pillow_heif

if pillow_heif.is_supported("image.heic"):
    heif_file = pillow_heif.open_heif("image.heic", convert_hdr_to_8bit=False)
    print("image size:", heif_file.size)
    print("image mode:", heif_file.mode)
    print("image data length:", len(heif_file.data))
    print("image data stride:", heif_file.stride)

Get decoded image data as a Numpy array

import numpy as np
import pillow_heif

if pillow_heif.is_supported("input.heic"):
    heif_file = pillow_heif.open_heif("input.heic")
    np_array = np.asarray(heif_file)

Accessing Depth Images

from PIL import Image
from pillow_heif import register_heif_opener
import numpy as np

register_heif_opener()

im = Image.open("../tests/images/heif_other/pug.heic")
if im.info["depth_images"]:
    depth_im = im.info["depth_images"][0]  # Access the first depth image (usually there will be only one).
    # Depth images are instances of `class HeifDepthImage(BaseImage)`,
    # so work with them as you would with any usual image in pillow_heif.
    # Depending on what you need the depth image for, you can convert it to a NumPy array or convert it to a Pillow image.
    pil_im = depth_im.to_pillow()
    np_im = np.asarray(depth_im)
    print(pil_im)
    print(pil_im.info["metadata"])

More Information

Wheels

Wheels tablemacOS
Intel
macOS
Silicon
Windows*musllinux*manylinux*
CPython 3.10✅✅✅✅✅
CPython 3.11✅✅✅✅✅
CPython 3.12✅✅✅✅✅
CPython 3.13✅✅✅✅✅
CPython 3.14✅✅✅✅✅
CPython 3.14t✅✅✅✅✅
CPython 3.15✅✅✅✅✅
CPython 3.15t✅✅✅✅✅
PyPy 3.11 v7.3✅✅✅N/A✅

* x86_64, aarch64 wheels.

avif
heic
heif
opencv
pillow
python
python3

Project health

Overall

6.3/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

Latest release

1.8.0 · Sep 22, 2026

Releases this year

8

Significant stargazers

Dave Lage

248 followers · starred Nov 2025

Thien Tran

376 followers · starred Mar 2024

Onuralp SEZER

808 followers · starred Feb 2026

Sasha Koss

797 followers · starred Apr 2026

bigcat88/pillow_heif

Python library for working with HEIF images and plugin for Pillow.

Python

306

1,026 commits

updated Oct 11, 2026

See the code

README

pillow-heif

Test Wheels docs codecov

PythonVersion impl pypi Downloads Downloads

Mac OS Windows Linux Alpine Linux Raspberry Pi

Python bindings to libheif for working with HEIF images and plugin for Pillow.

Features:

  • Decoding of 8, 10, 12 bit HEIC files.
  • Encoding of 8, 10, 12 bit HEIC files.
  • EXIF, XMP, IPTC read & write support.
  • Support of multiple images in one file and a PrimaryImage attribute.
  • Adding & removing thumbnails.
  • Grid(tiled) image encoding, like Apple devices do.
  • Reading of Depth Images.
  • (beta) Reading of Auxiliary Images by johncf
  • Adding HEIF support to Pillow in one line of code as a plugin.

Note: The light version pi-heif of this project is discontinued, 1.4.0 is its final release.

Install

python3 -m pip install -U pip
python3 -m pip install pillow-heif

Example of use as a Pillow plugin

from PIL import Image
from pillow_heif import register_heif_opener

register_heif_opener()

im = Image.open("image.heic")  # do whatever need with a Pillow image
im = im.rotate(13)
im.save(f"rotated_image.heic", quality=90)

16 bit PNG to 10 bit HEIF using OpenCV

import cv2
import pillow_heif

cv_img = cv2.imread("16bit_with_alpha.png", cv2.IMREAD_UNCHANGED)
heif_file = pillow_heif.from_bytes(
    mode="BGRA;16",
    size=(cv_img.shape[1], cv_img.shape[0]),
    data=bytes(cv_img)
)
heif_file.save("RGBA_10bit.heic", quality=-1)

8/10/12 bit HEIF to 8/16 bit PNG using OpenCV

import numpy as np
import cv2
import pillow_heif

heif_file = pillow_heif.open_heif("image.heic", convert_hdr_to_8bit=False, bgr_mode=True)
np_array = np.asarray(heif_file)
cv2.imwrite("image.png", np_array)

Accessing decoded image data

import pillow_heif

if pillow_heif.is_supported("image.heic"):
    heif_file = pillow_heif.open_heif("image.heic", convert_hdr_to_8bit=False)
    print("image size:", heif_file.size)
    print("image mode:", heif_file.mode)
    print("image data length:", len(heif_file.data))
    print("image data stride:", heif_file.stride)

Get decoded image data as a Numpy array

import numpy as np
import pillow_heif

if pillow_heif.is_supported("input.heic"):
    heif_file = pillow_heif.open_heif("input.heic")
    np_array = np.asarray(heif_file)

Accessing Depth Images

from PIL import Image
from pillow_heif import register_heif_opener
import numpy as np

register_heif_opener()

im = Image.open("../tests/images/heif_other/pug.heic")
if im.info["depth_images"]:
    depth_im = im.info["depth_images"][0]  # Access the first depth image (usually there will be only one).
    # Depth images are instances of `class HeifDepthImage(BaseImage)`,
    # so work with them as you would with any usual image in pillow_heif.
    # Depending on what you need the depth image for, you can convert it to a NumPy array or convert it to a Pillow image.
    pil_im = depth_im.to_pillow()
    np_im = np.asarray(depth_im)
    print(pil_im)
    print(pil_im.info["metadata"])

More Information

Wheels

Wheels tablemacOS
Intel
macOS
Silicon
Windows*musllinux*manylinux*
CPython 3.10✅✅✅✅✅
CPython 3.11✅✅✅✅✅
CPython 3.12✅✅✅✅✅
CPython 3.13✅✅✅✅✅
CPython 3.14✅✅✅✅✅
CPython 3.14t✅✅✅✅✅
CPython 3.15✅✅✅✅✅
CPython 3.15t✅✅✅✅✅
PyPy 3.11 v7.3✅✅✅N/A✅

* x86_64, aarch64 wheels.

avif
heic
heif
opencv
pillow
python
python3

Project health

Overall

6.3/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

Latest release

1.8.0 · Sep 22, 2026

Releases this year

8

Significant stargazers

Dave Lage

248 followers · starred Nov 2025

Thien Tran

376 followers · starred Mar 2024

Onuralp SEZER

808 followers · starred Feb 2026

Sasha Koss

797 followers · starred Apr 2026