Closed jaddison closed 7 years ago
Thumbnail information is wrong. If a jpeg has thumbnail, it must have 1st IFD and JPEGInterchangeFormatLength in Exif IFD(exif["Exif"][piexif.ExifIFD.JPEGInterchangeFormatLength]) value. JPEGInterchangeFormatLength means byte size of thumbnail. Your image has thumbnail's information, but it shows thumbnail's size as byte is zero, so remove thumbnail's information.
del exif["1st"]
del exif["thumbnail"]
piexif.dump(exif)
Shouldn't this kind of resiliency be built into this library?
Not everyone is going to know the intricacies of exif and all the special cases surrounding it?
It doesn't need to built in it into this library. In this case, zero byte data was passed and this library said "It's not JPEG". It's correct.
I understand what you're saying, but there's no easy way for someone to know that was the problem.
Maybe the library could raise an InvalidEXIFThumbnailError exception instead. Or even simpler, change the error text to say "EXIF thumbnail is not JPEG". Then the user of the library could at least know what the issue is.
Also if this exception was mentioned in the docs and what to do on this situation - ie remove the thumbnail from the exif dictionary - then that would help users.
Would you like me to create a PR?
PullRequest welcome. I want simpler solution.
Thank you : )
You're welcome!
Are you able to push a new version to pypi?
Thumbnail information is wrong. If a jpeg has thumbnail, it must have 1st IFD and JPEGInterchangeFormatLength in Exif IFD(exif["Exif"][piexif.ExifIFD.JPEGInterchangeFormatLength]) value. JPEGInterchangeFormatLength means byte size of thumbnail. Your image has thumbnail's information, but it shows thumbnail's size as byte is zero, so remove thumbnail's information.
del exif["1st"] del exif["thumbnail"] piexif.dump(exif)
I was getting the same error and this helped! Thanks! I ended up deleting all the keys in the exif dictionary other than those that I required
Thumbnail information is wrong. If a jpeg has thumbnail, it must have 1st IFD and JPEGInterchangeFormatLength in Exif IFD(exif["Exif"][piexif.ExifIFD.JPEGInterchangeFormatLength]) value. JPEGInterchangeFormatLength means byte size of thumbnail. Your image has thumbnail's information, but it shows thumbnail's size as byte is zero, so remove thumbnail's information.
del exif["1st"] del exif["thumbnail"] piexif.dump(exif)
This is the right solution! thanks
I'm seeing a crash with the following image something related to saving a resized version of the image (and updating the exif info):
Snippet of code that works for most images, but not the above:
Traceback:
After a quick debug, it looks like
exif_dict["thumbnail"]
isb""
.