dabo Commit
Revision 6510
Date: 2011-03-29 17:39:59 -0700 (Tue, 29 Mar 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6510

Changed:
U   trunk/dabo/ui/uiwx/dImage.py

Log:
Fixed the AttributeErrors that were raised when loading non-jpeg images.


Diff:
Modified: trunk/dabo/ui/uiwx/dImage.py
===================================================================
--- trunk/dabo/ui/uiwx/dImage.py        2011-03-29 23:15:08 UTC (rev 6509)
+++ trunk/dabo/ui/uiwx/dImage.py        2011-03-30 00:39:59 UTC (rev 6510)
@@ -20,16 +20,15 @@
 
 # See if PIL is installed
 _USE_PIL = True
-_ORIENTATION_TAG = None
 try:
        from PIL import Image
-       _ORIENTATION_TAG = 274
-       ## The tag number is a constant, so no need to calculate it each time.
-       #from PIL.ExifTags import TAGS
-       #_ORIENTATION_TAG = [tagnum for tagnum, tagname in TAGS.items()
-       #               if tagname == "Orientation"][0]
 except ImportError:
        _USE_PIL = False
+## The tag number is a constant, so no need to calculate it each time.
+#from PIL.ExifTags import TAGS
+#_ORIENTATION_TAG = [tagnum for tagnum, tagname in TAGS.items()
+#              if tagname == "Orientation"][0]
+_ORIENTATION_TAG = 274
 
 # The EXIF rotation values do not lend themselves easily to rotation
 # calculation, so I've defined my own for this class. These next two
@@ -307,9 +306,13 @@
                        if _USE_PIL:
                                try:
                                        pil_img = Image.open(val)
+                                       # Only jpeg images support this
                                        exif = pil_img._getexif()
                                        orientation = 
exif.get(_ORIENTATION_TAG, 1)
                                        self._displayState = 
_exifToImg(orientation)
+                               except AttributeError:
+                                       # Not a jpeg, or not a version with the 
_getexif() method
+                                       pass
                                except IOError:
                                        # Bad image, or no exif data available
                                        pass



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to