changeset 210:f983d1239a67

text_x_arnica: return on ioerror if the image is truncated
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 05 Aug 2008 16:21:59 +0200
parents 475844e1d7a3
children da38f8d6693b
files data/plugin/parser/text_x_arnica.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/parser/text_x_arnica.py	Mon Aug 04 13:10:18 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Tue Aug 05 16:21:59 2008 +0200
@@ -559,7 +559,11 @@
                         exif = im_obj._getexif()
                     except AttributeError:
                         exif = None
-                    im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS)
+                    try:
+                        im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS)
+                    except IOError:
+                        # image file is truncated
+                        return
                     if exif:
                         try:
                             process = {
@@ -583,7 +587,11 @@
                     buf.close()
 
             if not cache.exists(self.request, thumbnail):
-                im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
+                try:
+                    im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
+                except IOError:
+                    # image file is truncated
+                    return
                 buf = StringIO.StringIO()
                 im_obj.save(buf, image_type)
                 buf.flush()