I ran into a problem when trying to use it with images that had no EXIF thumbnail—instead of lib.Exif(self.data).thumbnail being set to None, it's a zero-length byte array. So when the exif_thumbnail() function runs, it errors out because constructing JPEGImage(blob=None) is gonna throw an error.
A workaround is below (or here, though I suspect this is just papering over an upstream problem in a function where None should be returned, and instead it's getting wrapped as a byte array.
@property
def exif_thumbnail(self):
""" EXIF thumbnail.
:return: EXIF thumbnail in JPEG format
:rtype: str
"""
try:
thumb = lib.Exif(self.data).thumbnail
if len(thumb) == 0:
return None
return JPEGImage(blob=thumb)
except lib.ExifException:
return None
Thanks for your work on this library.
I ran into a problem when trying to use it with images that had no EXIF thumbnail—instead of
lib.Exif(self.data).thumbnail
being set toNone
, it's a zero-length byte array. So when theexif_thumbnail()
function runs, it errors out because constructingJPEGImage(blob=None)
is gonna throw an error.A workaround is below (or here, though I suspect this is just papering over an upstream problem in a function where
None
should be returned, and instead it's getting wrapped as a byte array.