Resize podcast cover art if it's too big (bug 1110)

Some feeds have cover art bigger than the size of my
laptop's screen. Which make the podcast settings dialog
really hard to use (close button out of screen).

The parameter MAX_SIZE was already defined, and just
waiting to be used.
This commit is contained in:
psychedelys 2010-08-21 00:10:44 +02:00 committed by Thomas Perl
parent 92bf1255c4
commit 40a9d0a2b9

View file

@ -76,7 +76,7 @@ class CoverDownloader(ObservableService):
"""
# Maximum width/height of the cover in pixels
MAX_SIZE = 400
MAX_SIZE = 360
def __init__(self):
signal_names = ['cover-available', 'cover-removed']
@ -192,6 +192,18 @@ class CoverDownloader(ObservableService):
if pixbuf is None:
pixbuf = self.get_default_cover(channel)
# Resize if width is too large
if pixbuf.get_width() > self.MAX_SIZE:
f = float(self.MAX_SIZE)/pixbuf.get_width()
(width, height) = (int(pixbuf.get_width()*f), int(pixbuf.get_height()*f))
pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
# Resize if height is too large
if pixbuf.get_height() > self.MAX_SIZE:
f = float(self.MAX_SIZE)/pixbuf.get_height()
(width, height) = (int(pixbuf.get_width()*f), int(pixbuf.get_height()*f))
pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
if async:
self.notify('cover-available', channel.url, pixbuf)
else: