Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2010-02-25 21:26:12 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2010-02-25 21:26:12 (GMT)
commit0f2d04be85a7742451958209819a70b4f3567862 (patch)
tree670d2be5b584f7380d9f69338a7f72c87b21d68a
parentf829b15c6e507d8e30253645b8b72fc80b210f2a (diff)
Load any image format pixbuf supports
-rw-r--r--gui/page.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/gui/page.py b/gui/page.py
index 5b164a9..1d8d859 100644
--- a/gui/page.py
+++ b/gui/page.py
@@ -51,6 +51,9 @@ from gui import theme
from globals import Globals
+THUMB_SIZE = min(gtk.gdk.screen_width(), gtk.gdk.screen_height()) / 2
+
+
class Page(hippo.CanvasBox):
def __init__(self, **kwargs):
@@ -308,9 +311,7 @@ class Page(hippo.CanvasBox):
if hasattr(obj, 'image_blob') and journal_object and journal_object.file_path:
logging.debug('Getting journal object: %r, %s', journal_object, journal_object.file_path)
# Set the image now
- f = open(journal_object.file_path, 'r')
- raw = f.read()
- f.close()
+ raw = _load_image(journal_object.file_path)
obj.image = str(journal_object.metadata['title'])
obj.image_blob = raw
# refresh the image
@@ -364,6 +365,12 @@ class Page(hippo.CanvasBox):
#player.uri = sound_file
player.raw = obj.sound_blob
player.play()
-
-
-
+
+def _load_image(file_name):
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_name,
+ THUMB_SIZE, THUMB_SIZE)
+ if pixbuf is None:
+ return None
+ stream = StringIO.StringIO()
+ pixbuf.save_to_callback(lambda data: stream.write(data), 'png')
+ return stream.getvalue()