from PIL import Image
from fnmatch import fnmatch
from os import walk
from os.path import join
from distutils.dir_util import copy_tree

extension = "*.png"
copy_tree("./gui", "./gui_2")

for path, subdirs, files in walk("./gui_2"):
    for name in files:
        if fnmatch(name, extension):
            img = Image.open(join(path, name))
            img = img.convert("RGBA")

            pixdata = img.load()

            # Clean the background noise, if color != white, then set to black.
            for y in range(img.size[1]):
                for x in range(img.size[0]):
                    if pixdata[x, y] == (255, 255, 255, 255):
                        pixdata[x, y] = (0, 0, 0, 255)

            name = name.replace(".png", "_alt.png")
            img.save(join(path, name))
