diff --git a/scripts/icons_update.py b/scripts/icons_update.py index ea44ca97c..c152f55be 100644 --- a/scripts/icons_update.py +++ b/scripts/icons_update.py @@ -165,6 +165,21 @@ for fname in os.listdir(export_dir): fnames.add(fname) +def crop_image(img): + w, h = img.size + if h == w: + return img + normal = min(h, w) + diff_w = w - normal + diff_h = h - normal + crop_top = diff_h // 2 + crop_bot = diff_h // 2 + diff_h % 2 + crop_left = diff_w // 2 + crop_right = diff_w // 2 + diff_w % 2 + box = (crop_left, crop_top, w - crop_right, h - crop_bot) + return img.crop(box) + + def get_icon_file(request): """ Get the iconFile field value and find proper @@ -190,6 +205,7 @@ def get_icon_file(request): except KeyError: fullpath = sizes[max(sizes)] img = Image.open(fullpath) + img = crop_image(img) img.thumbnail(ICON_SIZE, Image.ANTIALIAS) else: img = Image.open(fullpath) diff --git a/scripts/renders_update.py b/scripts/renders_update.py index e57fd5486..dfe88e448 100644 --- a/scripts/renders_update.py +++ b/scripts/renders_update.py @@ -58,11 +58,27 @@ toupdate = existing.intersection(needed) toadd = needed.difference(existing) +def crop_image(img): + w, h = img.size + if h == w: + return img + normal = min(h, w) + diff_w = w - normal + diff_h = h - normal + crop_top = diff_h // 2 + crop_bot = diff_h // 2 + diff_h % 2 + crop_left = diff_w // 2 + crop_right = diff_w // 2 + diff_w % 2 + box = (crop_left, crop_top, w - crop_right, h - crop_bot) + return img.crop(box) + + def get_render(type_id): fname = '{}.png'.format(type_id) fullpath = os.path.join(export_dir, fname) img = Image.open(fullpath) if img.size != RENDER_SIZE: + img = crop_image(img) img.thumbnail(RENDER_SIZE, Image.ANTIALIAS) return img diff --git a/staticdata/icons/icon107_12.png b/staticdata/icons/icon107_12.png index 0b907587e..1bf43c7e2 100644 Binary files a/staticdata/icons/icon107_12.png and b/staticdata/icons/icon107_12.png differ diff --git a/staticdata/icons/icon109_64_1.png b/staticdata/icons/icon109_64_1.png index d1fa7dc82..7563b2257 100644 Binary files a/staticdata/icons/icon109_64_1.png and b/staticdata/icons/icon109_64_1.png differ diff --git a/staticdata/icons/icon109_64_2.png b/staticdata/icons/icon109_64_2.png index 876929af5..57d3548da 100644 Binary files a/staticdata/icons/icon109_64_2.png and b/staticdata/icons/icon109_64_2.png differ