-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptimize.py
58 lines (49 loc) · 1.61 KB
/
optimize.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
import os
import sys
from PIL import Image, ImageDraw
if len(sys.argv) != 2:
print("No path specified")
exit()
directory = sys.argv[1]
# All of the Bolt likes and Bonk are ignored due to them being able to wear all armor
not_optimized = [
"Bonk",
"Boltar",
"Blindolt",
"Boltash",
"Bombolt",
"Colt",
"Wizolt",
"Soult",
"Throlt",
"Jumpolt",
"Diabolt",
"Bold",
"Barista",
"Usain",
"Bush",
"Polt",
"Achievements",
"Icons"
]
for folder in os.walk(directory + '/sprites'):
for filename in folder[2]:
if filename.endswith('.png'):
# Path to image
path = f"{folder[0]}/{filename}"
# Open the image
with Image.open(path).convert("RGBA") as im:
# Get all body texture
if path.endswith('Body.png') and not any(x in path for x in not_optimized):
# 24 or 30 depending on Aria or Coda, idk why
height = int(im.size[1] / 14)
# Transparent rectangle used to overwrite the armor with
rect = Image.new("RGBA", (528, height), (255, 255, 255, 0))
# The armor lines we'll delete
deleted_lines = [1,2,3,4,6,7,8,13]
# Paste the rectangle on each lines
for line in deleted_lines:
im.paste(rect, (0, line * height))
# Save the image
im.save(path, "PNG", optimize = True)
print("Done optimizing " + path.replace(directory, '~'))