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

exifread.heic.NoParser: hdlr #184

Open honzajavorek opened 1 year ago

honzajavorek commented 1 year ago

Using version 3 of exif-py, it crashes when trying to parse a .HEIC photo from an iPhone, e.g. the one I'm attaching zipped here: IMG_4733.HEIC.zip

/Users/honza/Downloads/cindy_test/IMG_5394.HEIC
Traceback (most recent call last):
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/heic.py", line 171, in get_parser
    return defs[box.name]
           ~~~~^^^^^^^^^^
KeyError: 'hdlr'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Projects/cindy/cindy/__main__.py", line 22, in main
    tags = exifread.process_file(f)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/__init__.py", line 137, in process_file
    offset, endian, fake_exif = _determine_type(fh)
                                ^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/__init__.py", line 109, in _determine_type
    offset, endian = heic.find_exif()
                     ^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/heic.py", line 268, in find_exif
    meta = self.expect_parse('meta')
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/heic.py", line 159, in expect_parse
    return self.parse_box(box)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/heic.py", line 177, in parse_box
    probe(box)
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/heic.py", line 195, in _parse_meta
    psub = self.get_parser(box)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/honza/Library/Caches/pypoetry/virtualenvs/cindy-WgoVcAt6-py3.11/lib/python3.11/site-packages/exifread/heic.py", line 173, in get_parser
    raise NoParser(box.name) from err
exifread.heic.NoParser: hdlr
heckler commented 9 months ago

Since this is still an issue as of v 3.0.0, for anyone facing this issue, downgrading to the latest 2.x release solved it for me:

python -m pip install "exifread<3"