Icon resizing diagnostics/robustness

This commit is contained in:
Ciaran Gultnieks 2013-08-21 21:47:48 +01:00
parent 055a26d994
commit eec320a08d

View file

@ -215,14 +215,18 @@ def delete_disabled_builds(apps, apkcache, repodirs):
del apkcache[apkfilename] del apkcache[apkfilename]
def resize_icon(iconpath): def resize_icon(iconpath):
im = Image.open(iconpath) try:
if any(length > max_icon_size for length in im.size): im = Image.open(iconpath)
print iconpath, "is too large:", im.size if any(length > max_icon_size for length in im.size):
im.thumbnail((max_icon_size, max_icon_size), Image.ANTIALIAS) print iconpath, "is too large:", im.size
print iconpath, "new size:", im.size im.thumbnail((max_icon_size, max_icon_size), Image.ANTIALIAS)
im.save(iconpath, "PNG") print iconpath, "new size:", im.size
else: im.save(iconpath, "PNG")
print iconpath, "is small enough:", im.size else:
if options.verbose:
print iconpath, "is small enough:", im.size
except Exception,e:
print "ERROR: Failed processing {0} - {1}".format(iconpath, e)
def resize_all_icons(repodirs): def resize_all_icons(repodirs):
"""Resize all icons that exceed the max size """Resize all icons that exceed the max size