Handle error on thumbnail generation if blob is None
authorThierry Florac <tflorac@ulthar.net>
Wed, 06 Feb 2019 09:38:32 +0100
changeset 187 c04ae9beeb08
parent 186 a568f98546e8
child 188 185fd94902f4
Handle error on thumbnail generation if blob is None
src/pyams_file/image.py
--- a/src/pyams_file/image.py	Tue Feb 05 16:43:23 2019 +0100
+++ b/src/pyams_file/image.py	Wed Feb 06 09:38:32 2019 +0100
@@ -80,7 +80,10 @@
         else:
             return None
         # check format
-        image = Image.open(self.context.get_blob(mode='r'))
+        blob = self.context.get_blob(mode='r')
+        if blob is None:
+            return None
+        image = Image.open(blob)
         if not format:
             format = image.format
         format = format.upper()