Skip to main content

A decoder of HEIF format of images

Project description

cykooz.heif is simple python wrapper for the library libheif-rs.

RawHeifImage is a simple wrapper around low level HEIF-decoder.

CHANGELOG

Usage Examples

Read HEIF-image from file:

from cykooz.heif.image import RawHeifImage

img = RawHeifImage.from_path('data/test.heif')
assert img.width == 3024
assert img.height == 4032
assert img.mode == 'RGB'
assert len(img.data) == 36578304
assert img.stride == 9072
assert len(img.exif) == 2026

Read HEIF-image from file-like object:

from cykooz.heif.image import RawHeifImage

with open('data/test.heif') as fp
    img = RawHeifImage.from_stream(fp)
    assert img.width == 3024
    assert img.height == 4032

Also package provides an opener plugin for PIL (Pillow):

from PIL import Image
from cykooz.heif.pil import register_heif_opener

register_heif_opener()
img = Image.open('data/test.heif')
assert isinstance(img, Image.Image)
assert img.size == (3024, 4032)
assert img.mode == 'RGB'
assert img.getpixel((100, 100)) == (73, 74, 69)
img.save('test.jpg', 'JPEG')

Installation from source

System requirements:

Ubuntu 22.04

$ sudo add-apt-repository ppa:strukturag/libheif
$ sudo add-apt-repository ppa:strukturag/libde265
$ sudo apt-get install build-essential python3-dev libheif-dev curl clang
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ source $HOME/.cargo/env
$ pip3 install .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cykooz.heif-1.0.1.tar.gz (14.3 kB view hashes)

Uploaded Source

Built Distributions

cykooz.heif-1.0.1-cp312-cp312-manylinux_2_28_x86_64.whl (4.7 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.28+ x86-64

cykooz.heif-1.0.1-cp311-cp311-manylinux_2_28_x86_64.whl (4.7 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

cykooz.heif-1.0.1-cp310-cp310-manylinux_2_28_x86_64.whl (4.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

cykooz.heif-1.0.1-cp39-cp39-manylinux_2_28_x86_64.whl (4.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

cykooz.heif-1.0.1-cp38-cp38-manylinux_2_28_x86_64.whl (4.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page