-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathachievement.py
61 lines (49 loc) · 1.74 KB
/
achievement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from os import walk
from PIL import Image, ImageDraw
import numpy as np
directory = '/home/warze/GitHub/CodaFlavors'
custom_directory = input(f'Enter directory of your GitHub (Leave empty to default to {directory})')
if custom_directory != '':
directory = custom_directory
path = directory + '/preview_scr/'
exitpath = directory + '/sprites/Achievements/'
characters = []
bodies = {}
heads = {}
for folder in walk(directory + '/sprites'):
for filename in folder[2]:
path = folder[0] + '/' + filename
if filename.endswith('Body.png'):
charname = filename.replace('Body.png','')
bodies[charname] = path
characters.append(charname)
if filename.endswith('Head.png'):
charname = filename.replace('Head.png','')
heads[charname] = path
# We don't care about these guys
characters.remove('Aria')
characters.remove('Bolt')
characters.remove('Coda')
print(characters)
for character in characters:
img = Image.open(directory + '/sprites/Achievements/0.png')
body = Image.open(bodies[character]).convert('RGBA')
head = Image.open(heads[character]).convert('RGBA')
if body.size[1] == 420:
size = 31
xoffset = 1
yoffset = 1
else:
size = 23
xoffset = 4
yoffset = 4
for x in range(0, size):
for y in range(0, size):
headdata = head.getpixel((x, y))
bodydata = body.getpixel((x, y))
if headdata[3] != 0:
img.putpixel((x + xoffset, y + yoffset), headdata)
elif bodydata[3] != 0:
img.putpixel((x + xoffset, y + yoffset), bodydata)
img.save(exitpath + character + '.png')
print("Done with " + character)