ianare / exif-py

Easy to use Python module to extract Exif metadata from digital image files.
BSD 3-Clause "New" or "Revised" License
831 stars 191 forks source link

ignore unknown parsers. fix #160 #175

Closed hpoul closed 1 year ago

hpoul commented 1 year ago

Trying to parse exif data from a HEIC file leads to error:

  File "/Users/herbert/Library/Caches/pypoetry/virtualenvs/cux-base-mqrrDLXf-py3.10/lib/python3.10/site-packages/exifread/heic.py", line 173, in get_parser
    raise NoParser(box.name) from err
exifread.heic.NoParser: hdlr

I have found a commit which was meant to just add typing, but changed the behavior from just ignoring unknown parsers to throwing an exception. Just ignoring unknown parsers and skip that "box" seems to work for me.

https://github.com/ianare/exif-py/commit/d0654ca4bd3b32ed890628a02d68fa7da37098d4#diff-24bbe7a21b2cb2816c8159fdf4930992d0458647adda5b84ce5a9f8e2af24997L133-L136

before returns None:

        method = 'parse_%s' % box.name
        return getattr(self, method, None)

after throws an error:

        try:
            return defs[box.name]
        except IndexError:
            raise NoParser(box.name)