Skip to main content

A library/tool to decode images in HEIC/HEIF format taken on Apple devices that contain HDR gain map.

Project description

apple-hdr-heic

A library/tool to decode photos (HEIC files) taken on an iPhone that contain HDR gain map, and convert it to a 48-bit (16-bit per channel) HDR representation as per Rec. 2100 with PQ transfer function.

Disclaimer: This project is NOT affiliated with, or endorsed by, Apple Inc. or any of its subsidiaries.

Pre-requisites

  • Python 3.10+
  • exiftool 12.54+
    • For Ubuntu or Debian, do sudo apt install libimage-exiftool-perl
    • For other Linux distros, search exiftool using your package manager
    • For Mac or Windows, follow the instructions in website
    • For Windows, it is also available via Scoop

Installation

Clone this repository, create a python environment and do:

pip install .

Usage

CLI tool:

apple-hdr-heic-decode input.heic output.png

Library usage:

from apple_hdr_heic import load_as_bt2100_pq, quantize_to_uint16

bt2100_pq = load_as_bt2100_pq("input.heic")
bt2100_pq_u16 = quantize_to_uint16(bt2100_pq)
cv2.imwrite("output.png", bt2100_pq_u16[:, :, ::-1])

The output file output.png does not contain the necessary cICP metadata that denotes it to have bt2020 (9) color primaries and smpte2084 (16) transfer characteristics.

To convert the above PNG to a 12-bit HDR AVIF file with appropriate metadata using libavif, do:

avifenc -s 4 -j 4 --min 1 --max 56 -a end-usage=q -a cq-level=10 -a tune=ssim -a color:enable-qm=1 \
    -a color:enable-chroma-deltaq=1 -d 12 --cicp 9/16/9 output.png output.avif

Development

Environment Set Up

Install uv.

Install nox using uv:

uv tool install nox

Unit Testing

nox -s test

Type Checking

nox -s typeck

Linting

nox -s lint

Formatting

nox -s style

Building

uv tool install flit
flit build --no-use-vcs

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

apple_hdr_heic-0.0.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

apple_hdr_heic-0.0.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file apple_hdr_heic-0.0.2.tar.gz.

File metadata

  • Download URL: apple_hdr_heic-0.0.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for apple_hdr_heic-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1bbbe16a9e89526c662dbbbd65812a5bdb99cabda59dd51220dcd6f4464bb58a
MD5 5d77104c29f290c7f86a4e325e7fd39b
BLAKE2b-256 07b22d5a1c54c10765ff107ffd8ba2dc5c68a4feb434bd348b25d7812fedaac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for apple_hdr_heic-0.0.2.tar.gz:

Publisher: release.yml on johncf/apple-hdr-heic

Attestations:

File details

Details for the file apple_hdr_heic-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for apple_hdr_heic-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c90f3fe167fb29302076989cffde9ee77c72f4e78e951d48f8736edd87c70806
MD5 b858ece7c8e1f4126ea649dc57f2b78c
BLAKE2b-256 ee80972da89aa67b54f57400495094512dbff22d4f653ca3af9833e89509e071

See more details on using hashes here.

Provenance

The following attestation bundles were made for apple_hdr_heic-0.0.2-py3-none-any.whl:

Publisher: release.yml on johncf/apple-hdr-heic

Attestations:

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