[ocrfeeder] widgetPresenter: Prevent problems when getting the Unpaper image preview



commit 9476d3340c244e05d047a6b95d2b69ed62f63105
Author: Joaquim Rocha <jrocha igalia com>
Date:   Thu Jul 1 15:35:24 2010 +0200

    widgetPresenter: Prevent problems when getting the Unpaper image preview
    
    Check the image path for existence and catch eventual exceptions.

 studio/widgetPresenter.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/studio/widgetPresenter.py b/studio/widgetPresenter.py
index c3d00de..0994233 100644
--- a/studio/widgetPresenter.py
+++ b/studio/widgetPresenter.py
@@ -911,7 +911,13 @@ class UnpaperDialog(gtk.Dialog):
 
     def __getPreviewImage(self, image_path):
         name = os.path.splitext(image_path)[0]
-        thumbnail_image = Image.open(image_path)
+        if not os.path.exists(image_path):
+            return
+        try:
+            thumbnail_image = Image.open(image_path)
+        except Exception, exception:
+            lib.debug(exception.message)
+            return
         thumbnail_image.thumbnail((150, 200), Image.ANTIALIAS)
         image_thumbnail_path = lib.getNonExistingFileName(name + '_thumb.png')
         thumbnail_image.save(image_thumbnail_path, format = 'PNG')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]