Skip to content

process_file() crashes on (some?) HEIF files #197

@patrick-brian-mooney

Description

@patrick-brian-mooney

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions