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

process_file() crashes on (some?) HEIF files

Open patrick-brian-mooney opened this issue 1 year ago • 1 comments

I have some files with .jpg extensions that are actually HEIF files. (I suspect it's the Android app for Instagram generating them on my phone, but haven't followed up.) Trying to process them with my normal processing script causes exiftool.process_file() to crash.

Here's a simplified version of the code causing the crash:

import exifread
with open("""IMG_20240322_014811_458.jpg""", 'rb') as f:
    tags = exifread.process_file(f, details=False)

Here's a stack trace showing what's happening:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 2, in <module>
  File "/home/patrick/Documents/programming/python_projects/photo-processing/lib/python3.8/site-packages/exifread/__init__.py", line 242, in process_file
    offset, endian = heic.find_exif()
  File "/home/patrick/Documents/programming/python_projects/photo-processing/lib/python3.8/site-packages/exifread/heic.py", line 240, in find_exif
    item_id = meta.subs['iinf'].exif_infe.item_id
AttributeError: 'NoneType' object has no attribute 'item_id'

It looks like heic.find_exif() is returning None, but later code isn't checking for that possibility.

And I'm attaching a copy of a file that causes the crash:

IMG_20240322_014811_458.jpg.zip

patrick-brian-mooney avatar Apr 11 '24 22:04 patrick-brian-mooney

Currently there is no support for hdlr boxes in the file.

Should not cause an exception though.

ianare avatar Apr 30 '25 17:04 ianare