"""Apaga do atlas do Tangler os logos de marcas (Gmail, Telegram, Facebook, GitHub) que so serviam aos links de contato da tela de creditos, que a versao web nao tem. Uso: clear-logos.py """ import sys from PIL import Image atlas, png = sys.argv[1:3] want = {"icongmail", "icontelegram", "iconfacebook", "icongithub"} regions, cur = {}, None for line in open(atlas, encoding="utf-8").read().splitlines(): if line and not line.startswith(" ") and ":" not in line and line != "atlas.png": cur = line.strip() elif cur and line.strip().startswith("xy:"): regions.setdefault(cur, {})["xy"] = tuple(int(v) for v in line.split(":")[1].split(",")) elif cur and line.strip().startswith("size:") and cur in regions: regions[cur]["size"] = tuple(int(v) for v in line.split(":")[1].split(",")) im = Image.open(png).convert("RGBA") for name in sorted(want): (x, y), (w, h) = regions[name]["xy"], regions[name]["size"] im.paste((0, 0, 0, 0), (x, y, x + w, y + h)) print("cleared", name, x, y, w, h) im.save(png, optimize=False)