-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicon.py
More file actions
25 lines (19 loc) · 673 Bytes
/
icon.py
File metadata and controls
25 lines (19 loc) · 673 Bytes
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
from PIL import Image
import os
def create_ico():
# Open the source image
img = Image.open('icon.jpg')
# Convert to RGBA if needed
if img.mode != 'RGBA':
img = img.convert('RGBA')
# Prepare different sizes needed for Windows
sizes = [(16,16), (32,32), (48,48), (64,64), (128,128), (256,256)]
icons = []
# Create each size
for size in sizes:
resized_img = img.resize(size, Image.Resampling.LANCZOS)
icons.append(resized_img)
# Save as ICO with all sizes included
icons[0].save('app.ico', format='ICO', sizes=sizes, append_images=icons[1:])
if __name__ == '__main__':
create_ico()