-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathicon_generator.py
33 lines (25 loc) · 947 Bytes
/
icon_generator.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
#!/usr/bin/env python3
import sys
from PIL import Image
from PIL import ImageOps
def usage():
print('usage: ./icon_generator.py <src_image>')
def main(filename):
icon_sizes = (16, 19, 32, 38, 48, 128)
src_image = Image.open(filename, 'r')
for size in icon_sizes:
icon = src_image.resize((size, size), Image.LANCZOS)
icon.save('extension/icons/icon{size}.png'.format(size=size))
if size == 19:
grayscale_icon = ImageOps.grayscale(icon)
grayscale_icon.save('extension/icons/icon{size}-disable.png'.format(size=size))
if size == 128:
ico_icon = src_image.resize((size, size), Image.LANCZOS)
ico_icon.save('extension/favicon.ico'.format(size=size))
ico_icon.save('app/favicon.ico'.format(size=size))
if __name__ == '__main__':
if len(sys.argv) != 2:
usage()
sys.exit(1)
filename = sys.argv[1]
main(filename)