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

manipulating an image w/o exif thumbnail throws error (includes workaround) #24

Open
benfry opened this issue Jul 12, 2019 · 0 comments

Comments

@benfry
Copy link

benfry commented Jul 12, 2019

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 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
@cbm755 cbm755 added this to the 0.7.0 milestone Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants