Andreas Preikschat has proposed merging lp:~googol-hush/openlp/thumb-creation 
into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/thumb-creation/+merge/63566

Hello,

NOTE: Due to feature freeze this proposal is targeted for Beta 3.

This improves the thumbnail creation speed of the image plugin (in the 
mediamanger).

Previously this took very long. It also needed many resources.

The time will (obviously) vary from computer to computer. Also some formats 
which support animation (gif, mng, ...) will take longer, as thumbnail creation 
does not work or has not been implemented (this is not a regression of this 
branch!).

http://olliwang.com/2010/01/30/creating-thumbnail-images-in-qt/
http://doc.trolltech.com/4.6/qimagereader.html
-- 
https://code.launchpad.net/~googol-hush/openlp/thumb-creation/+merge/63566
Your team OpenLP Core is requested to review the proposed merge of 
lp:~googol-hush/openlp/thumb-creation into lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2011-06-04 16:07:42 +0000
+++ openlp/core/lib/mediamanageritem.py	2011-06-06 15:12:37 +0000
@@ -391,21 +391,26 @@
             self.iconFromFile(image, thumb)
         return True
 
-    def iconFromFile(self, image, thumb):
+    def iconFromFile(self, image_path, thumb_path):
         """
         Create a thumbnail icon from a given image.
 
-        ``image``
+        ``image_path``
             The image file to create the icon from.
 
-        ``thumb``
-            The filename to save the thumbnail to
+        ``thumb_path``
+            The filename to save the thumbnail to.
         """
-        icon = build_icon(unicode(image))
-        pixmap = icon.pixmap(QtCore.QSize(88, 50))
-        ext = os.path.splitext(thumb)[1].lower()
-        pixmap.save(thumb, ext[1:])
-        return icon
+        ext = os.path.splitext(thumb_path)[1].lower()
+        reader = QtGui.QImageReader(image_path)
+        ratio = float(reader.size().width()) / float(reader.size().height())
+        reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88))
+        thumb = reader.read()
+        thumb.save(thumb_path, ext[1:])
+        if os.path.exists(thumb_path):
+            return build_icon(unicode(thumb_path))
+        # Fallback for files with animation support.
+        return build_icon(unicode(image_path))
 
     def loadList(self, list):
         raise NotImplementedError(u'MediaManagerItem.loadList needs to be '

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to