hMatoba / Piexif

Exif manipulation with pure python script.
MIT License
367 stars 81 forks source link

Get a `struct.error` when trying to load exif data #17

Closed rparent closed 8 years ago

rparent commented 8 years ago

II am reading several images coming from the same device (which means the EXIF version should be the same for each image), and sometimes the exif loading works fine but sometimes I get the following error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/renaud/src/backoffice/venv/lib/site-packages/piexif/_load.py", line 51, in load
    exif_dict["1st"] = exifReader.get_ifd_dict(pointer, "1st")
  File "/home/renaud/src/backoffice/venv/lib/site-packages/piexif/_load.py", line 92, in get_ifd_dict
    self.tiftag[pointer: pointer+2])[0]
struct.error: unpack requires a string argument of length 2

If it can help, this seems to happen only at a certain orientation (exif orientation = 6).

Here is an example image which gives me this error.

test

hMatoba commented 8 years ago

This jpeg's exif(1st IFD) is broken. I checked it on http://regex.info/exif.cgi

rparent commented 8 years ago

OK, thanks for the answer, and for the work on this package. I will check the reason why the exif is broken, it is weird...

In those cases, maybe piexif.load could load the rest of the exif with a warning if it is readable, or at least raise a clear exception indicating that the exif is broken ? Could save some time to other developers that will try to read broken exifs !

hMatoba commented 8 years ago

Exception... There are too many cases that exif are broken. I could support this case, but other cases, I can't support them until it happens.

MrfksIv commented 4 years ago

The same thing happens to this image even though the http://regex.info/exif.cgi manages to extract the exif. Any ideas? symbol-1070-f2d9459e-1ee6-4640-9a15-3fb00fd5100b-full