hMatoba / Piexif

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

piexif.load() with error: unpack requires a buffer of 2 bytes #129

Open wuxiangchao opened 2 years ago

wuxiangchao commented 2 years ago

fix method: add code into _load.py at line 108: if len(self.tiftag[pointer: pointer+2]) != 2: return ifd_dict

nandoflorestan commented 3 months ago

Here is an image that will cause this issue: https://read.nando.audio/images/warsaw-veturilo.jpg

The above solution does fix it.

And here is the stacktrace.

TaskError - taskid:scale_images:../output/images/warsaw-veturilo.jpg PythonAction Error Traceback (most recent call last): File "/home/nando/ythn/nando/read.nando.audio/.venv/lib/python3.10/site-packages/doit/action.py", line 461, in execute returned_value = self.py_callable(*self.args, **kwargs) File "/home/nando/ythn/nando/read.nando.audio/.venv/lib/python3.10/site-packages/nikola/plugins/task/scale_images.py", line 69, in process_image self.resize_image( File "/home/nando/ythn/nando/read.nando.audio/.venv/lib/python3.10/site-packages/nikola/image_processing.py", line 117, in resize_image exif = piexif.load(_im.info["exif"]) File "/home/nando/ythn/nando/read.nando.audio/.venv/lib/python3.10/site-packages/piexif/_load.py", line 49, in load exif_dict["Interop"] = exifReader.get_ifd_dict(pointer, "Interop") File "/home/nando/ythn/nando/read.nando.audio/.venv/lib/python3.10/site-packages/piexif/_load.py", line 108, in get_ifd_dict tag_count = struct.unpack(self.endian_mark + "H", struct.error: unpack requires a buffer of 2 bytes