changeset 84:93125407c585

text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 09 Jun 2008 19:17:19 +0200
parents efe22edd1887
children d705644861dc
files data/plugin/parser/text_x_arnica.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/parser/text_x_arnica.py	Sat Jun 07 21:45:04 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Mon Jun 09 19:17:19 2008 +0200
@@ -504,6 +504,8 @@
         path = AttachFile.getAttachDir(self.request, self.pagename, create=1)
         imagef = os.path.join(path, image)
 
+        if os.path.getsize(imagef) == 0:
+            return
 
         page = Page(self.request, self.pagename)
         cache_web = caching.CacheEntry(self.request, page, webnail, scope='item', use_pickle=True)
@@ -518,7 +520,11 @@
             cache_thumb.remove()
 
         if not cache_web.exists() or not cache_thumb.exists():
-            im_obj = Image.open(imagef)
+            try:
+                im_obj = Image.open(imagef)
+            except IOError:
+                return
+
             if not cache_web.exists():
                 if not self.image_for_webnail:
                     im_obj.thumbnail((self.webnail_width, self.webnail_width), Image.ANTIALIAS)