diff --git a/songs/Jonathan_Coulton/portal.jpg b/songs/Jonathan_Coulton/portal.jpg index 2a018c80..971c1d96 100644 Binary files a/songs/Jonathan_Coulton/portal.jpg and b/songs/Jonathan_Coulton/portal.jpg differ diff --git a/songs/Le_Donjon_de_Naheulbeuk/grimoire-audio.jpg b/songs/Le_Donjon_de_Naheulbeuk/grimoire-audio.jpg index 804ccb8a..47da0b09 100644 Binary files a/songs/Le_Donjon_de_Naheulbeuk/grimoire-audio.jpg and b/songs/Le_Donjon_de_Naheulbeuk/grimoire-audio.jpg differ diff --git a/songs/Le_Donjon_de_Naheulbeuk/t-as-pas-le-niveau.jpg b/songs/Le_Donjon_de_Naheulbeuk/t-as-pas-le-niveau.jpg index 9d730ab8..cd2c39dc 100644 Binary files a/songs/Le_Donjon_de_Naheulbeuk/t-as-pas-le-niveau.jpg and b/songs/Le_Donjon_de_Naheulbeuk/t-as-pas-le-niveau.jpg differ diff --git a/utils/resize-cover.py b/utils/resize-cover.py index 975c2386..c7f9daf3 100755 --- a/utils/resize-cover.py +++ b/utils/resize-cover.py @@ -8,14 +8,30 @@ import Image import glob -width = 128 -height = 128 - # Process song files covers = glob.glob('songs/*/*.jpg') for filename in covers: + source = Image.open(filename) - if source.size > (128, 128): - print "resizing : " + filename + + src_width = source.size[0] + src_height = source.size[1] + ratio = float(src_height) / float(src_width) + + width = 128 + height = 128 + error = 0.2 #0: always preserve ratio; 1: always square images + + #tolerate almost square images + if ratio < 1 - error or ratio > 1 + error: + #print "preserve ratio = ", ratio + #preserve important ratio + if src_width < src_height: + height = int(width * ratio) + elif src_height < src_width: + width = int(height * ratio) + + if src_width > width and src_height > height: + print "resize: ", filename, " from ", source.size, " to ", (width, height) target = source.resize((width, height), Image.ANTIALIAS) target.save(filename)