exif-py icon indicating copy to clipboard operation
exif-py copied to clipboard

KeyError: hdlr

Open JonathanRoth13 opened this issue 2 years ago • 1 comments

i encountered this error using python 3.9.2 and while trying to extract exif data from a HEIC file. 2022-01-18_screenshot_bumbling : bash

exifread

JonathanRoth13 avatar Jan 18 '22 20:01 JonathanRoth13

pip install "exifread<3" solved this for me.

I'm on macOS (Apple silicon).

aapris avatar Jun 02 '22 10:06 aapris

Works fine on macos, but fails on raspberrypi

helgeerbe avatar Nov 28 '22 21:11 helgeerbe

I just came across the same issue. No idea what 'hdlr' contains. In the exiv2 source it parses it with a function called parseHandler (in quicktimevideo.cpp). Just skipping it seems to work, though:

diff --git a/exifread/heic.py b/exifread/heic.py
index 1109d15..e61f833 100644
--- a/exifread/heic.py
+++ b/exifread/heic.py
@@ -158,6 +158,11 @@ def parse_meta (self, meta):
             # skip any unparsed data
             self.skip (box)

+    def parse_hdlr (self, box):
+        self.get_full (box)
+        # can I just ignore it?
+        self.skip (box)
+
     def parse_infe (self, box):
         self.get_full (box)
         if box.version >= 2:

samrushing avatar Feb 11 '23 22:02 samrushing

imho just ignoring it would be the right thing to do, i've created a PR #175

fwiw, the following monkey patch also seems to work for me..

def _monkey_patch_exifread():
    from exifread import HEICExifFinder
    from exifread.heic import NoParser

    _old_get_parser = HEICExifFinder.get_parser

    def _get_parser(self, box):
        try:
            return _old_get_parser(self, box)
        except NoParser:
            logger.warning("ignoring parser %s", box.name)
            return None

    HEICExifFinder.get_parser = _get_parser


_monkey_patch_exifread()

hpoul avatar Feb 27 '23 21:02 hpoul

Seems like this is not yet fully fixed? https://github.com/ianare/exif-py/issues/184

honzajavorek avatar Aug 06 '23 13:08 honzajavorek