Return 'None' when no photo, and ensure paletted images are converted to
authorAndrew Flegg <andrew@bleb.org>
Wed, 9 Jun 2010 22:23:34 +0000 (23:23 +0100)
committerAndrew Flegg <andrew@bleb.org>
Wed, 9 Jun 2010 22:23:34 +0000 (23:23 +0100)
RGB (should fix MB#6543)

package/src/org/maemo/hermes/engine/contact.py

index 8281d18..25a3144 100644 (file)
@@ -103,7 +103,11 @@ class Contact:
         EContactPhoto."""
         
         photo = self._contact.get_property('photo')
-        return cast(c_void_p(hash(photo)), POINTER(EContactPhoto))
+        pi = cast(c_void_p(hash(photo)), POINTER(EContactPhoto))
+        if photo is None or pi.contents.data.uri == '':
+            return None
+        else:
+            return pi
     
     
     # -----------------------------------------------------------------------
@@ -122,6 +126,9 @@ class Contact:
                     break
             
             im = Image.open(StringIO.StringIO(data))
+            if im.mode != 'RGB':
+                im.convert('RGB')
+                
             (w, h) = im.size
             if (h > w):
                 ##print u"Shrinking photo for %s as it's %d x %d" % (self._contact.get_name(), w, h)