예제 #1
0
import re
from image_processing import file

if __name__ == '__main__':
    pattern = re.compile('(.*)_\d+\.png')
    gifs = {}

    file.mkdir('image_processing/output')
    file.mkdir('image_processing/output/idle')

    for filename, im in file.iter_img('image_processing/input/Sprite'):
        stems = re.findall(pattern, filename)
        if len(stems):
            stem = stems[0]
            gifs.setdefault(stem, [])
            if 'shelldag' in stem:
                im = im.rotate(270, expand=True)
            gifs[stem].append(im.convert('RGB', dither=False))

    for stem in gifs:
        file.save_gif(gifs[stem], 'image_processing/output/idle/' + stem + '.gif', 200)
예제 #2
0
    return b, b.convert('1', dither=False)


if __name__ == '__main__':
    file.mkdir('image_processing/output')
    file.mkdir('image_processing/output/mask')
    file.mkdir('image_processing/output/mask/shadow')
    file.mkdir('image_processing/output/mask/color')

    capture = 'image_processing/input/Art Capture'
    for character in os.listdir(capture):
        directory = os.path.join(capture, character)
        if os.path.isdir(directory):
            mask = None
            alpha = None
            for filename, im in file.iter_img(directory):
                if '_PortraitMarquee_' in filename:
                    gray, a = get_lightest(im)
                    if not mask or not alpha:
                        mask = gray
                        alpha = a
                    else:
                        mask = ImageChops.lighter(mask, gray)
                        alpha = ImageChops.lighter(alpha, a)
            mask.putalpha(alpha)
            mask.save('image_processing/output/mask/shadow/' + character +
                      '.png')
            mask2, alpha2 = get_double(mask)
            mask2.putalpha(alpha2)
            mask2.save('image_processing/output/mask/color/' + character +
                       '.png')
예제 #3
0
from PIL import ImageOps
from image_processing import file

def dichotimize_gif(im):
    'Return frames of GIF converted to black and white and inverted.'
    frames = []
    for i in range(1000000):
        try:
            im.seek(i)
            bw = im.convert('1', dither=False)
            frame = ImageOps.invert(bw.convert('L'))
            frames.append(frame)
        except:
            break
    return frames

if __name__ == '__main__':
    file.mkdir('image_processing/output')
    file.mkdir('image_processing/output/throbber')

    for filename, im in file.iter_img('image_processing/input/throbber'):
        if filename.split('.')[-1] == 'gif':
            frames = dichotimize_gif(im)
            file.save_gif(frames, 'image_processing/output/throbber/' + filename)