Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HEIC parser reaches EOF inside get32() call #137

Open
Guymer opened this issue Dec 27, 2020 · 1 comment
Open

HEIC parser reaches EOF inside get32() call #137

Guymer opened this issue Dec 27, 2020 · 1 comment

Comments

@Guymer
Copy link

Guymer commented Dec 27, 2020

The attached HEIC image was taken with an iPhone XR and when I try to extract the metadata using exifread.process_file(fobj, details = False) then I get the following Traceback:

Traceback (most recent call last):
  File "create_photo_album_JSON.py", line 83, in <module>
    tags = exifread.process_file(fobj, details = False)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/__init__.py", line 242, in process_file
    offset, endian = heic.find_exif()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/heic.py", line 229, in find_exif
    meta = self.expect_parse('meta')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/heic.py", line 122, in expect_parse
    return self.parse_box(box)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/heic.py", line 133, in parse_box
    probe(box)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/heic.py", line 155, in parse_meta
    psub(box)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/heic.py", line 221, in parse_iloc
    extent_length = self.get_int(box.length_size)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/heic.py", line 74, in get_int
    return self.get32()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exifread/heic.py", line 58, in get32
    return struct.unpack('>L', self.get(4))[0]
struct.error: unpack requires a buffer of 4 bytes

The script was run on MacOS Big Sur 11.1 using Python 3.8.6 and ExifRead 2.3.1 from MacPorts.

@nickdimitroff
Copy link
Contributor

nickdimitroff commented Nov 4, 2022

Not sure what's going on, but I hit a different error with this file. It didn't like this hdlr thing.

DEBUG HEIC: skipping <box 'hdlr'>

Was able to get past the error with this inside of get_parser in heic.py.

        except (IndexError, KeyError) as err:
            #raise NoParser(box.name) from err
            self.skip(box)

and get exif data out

...
INFO EXIF LensMake (ASCII): Apple
INFO EXIF LensModel (ASCII): iPhone XR back camera 4.25mm f/1.8
INFO EXIF LensSpecification (Ratio): [17/4, 17/4, 9/5, 9/5]
INFO EXIF MakerNote (Undefined): [65, 112, 112, 108, 101, 32, 105, 79, 83, 0, 0, 1, 77, 77, 0, 25, 0, 1, 0, 9, ... ]
INFO EXIF MeteringMode (Short): Pattern
INFO EXIF OffsetTime (ASCII): Z
...

May be a fix to #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants