improved thumbnail creation speed

This commit is contained in:
Andreas Preikschat 2011-06-03 17:57:56 +02:00
parent 59f520ab6c
commit 47936e34a7

View File

@ -391,21 +391,23 @@ class MediaManagerItem(QtGui.QWidget):
self.iconFromFile(image, thumb) self.iconFromFile(image, thumb)
return True return True
def iconFromFile(self, image, thumb): def iconFromFile(self, image_path, thumb_path):
""" """
Create a thumbnail icon from a given image. Create a thumbnail icon from a given image.
``image`` ``image_path``
The image file to create the icon from. The image file to create the icon from.
``thumb`` ``thumb_path``
The filename to save the thumbnail to The filename to save the thumbnail to.
""" """
icon = build_icon(unicode(image)) ext = os.path.splitext(thumb_path)[1].lower()
pixmap = icon.pixmap(QtCore.QSize(88, 50)) reader = QtGui.QImageReader(image_path)
ext = os.path.splitext(thumb)[1].lower() reader.setScaledSize(QtCore.QSize(
pixmap.save(thumb, ext[1:]) reader.size().width() / reader.size().height() * 88, 88))
return icon thumb = reader.read()
thumb.save(thumb_path, ext[1:])
return build_icon(unicode(thumb_path))
def loadList(self, list): def loadList(self, list):
raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' raise NotImplementedError(u'MediaManagerItem.loadList needs to be '