From 54b084658837f631b5dc42175e65826de080ff87 Mon Sep 17 00:00:00 2001 From: night199uk Date: Mon, 17 Aug 2026 12:17:36 -0500 Subject: [PATCH] heif: fix syntax for pillow_heif >= 0.22.0 allows using latest pillow_heif (at this time 1.5.0) --- hif/heif_io.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hif/heif_io.py b/hif/heif_io.py index 4598120..8c21a34 100644 --- a/hif/heif_io.py +++ b/hif/heif_io.py @@ -10,6 +10,7 @@ import subprocess import tempfile from contextlib import contextmanager +from PIL import Image try: import pillow_heif except ImportError: @@ -18,8 +19,7 @@ open_heif = pillow_heif.open_heif except AttributeError: open_heif = pillow_heif.open -pillow_heif.register_avif_opener() - +pillow_heif.register_heif_opener() def get_version(): def toint(p): @@ -264,13 +264,13 @@ def linearize(data, nclx): def read(opts): - heif = open_heif(opts.input, convert_hdr_to_8bit=False) + heif = Image.open(opts.input) width, height = heif.size - print(f'found image: {width}x{height} pixels, {heif.bit_depth} bits') + print(f'found image: {width}x{height} pixels, {heif.info["bit_depth"]} bits') if opts.width and opts.height: - heif = pillow_heif.thumbnail(heif, max(opts.width, opts.height)) + heif.resize((opts.width, opts.height)) with Timer('decoding'): - rgb = numpy.asarray(heif, dtype=numpy.float32) / (2**heif.bit_depth - 1) + rgb = numpy.asarray(heif, dtype=numpy.float32) / (2**heif.info["bit_depth"] - 1) end = time.time() nclx = get_nclx(heif.info) profile = None