-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_icons.py
More file actions
52 lines (41 loc) · 1.59 KB
/
Copy pathmake_icons.py
File metadata and controls
52 lines (41 loc) · 1.59 KB
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
#!/usr/bin/env python3
"""
Generate platform icon files (.ico for Windows, .icns for macOS) from the
PortusSIM logo PNGs in assets/logo/.
Usage: python make_icons.py
Requires Pillow (already in requirements.txt). The .icns is built with Pillow
where possible; on macOS you can alternatively use the native `iconutil`
(see build_mac.sh) for a perfectly conformant .icns.
"""
import os
from PIL import Image
HERE = os.path.dirname(os.path.abspath(__file__))
LOGO = os.path.join(HERE, "assets", "logo")
def _load(size):
p = os.path.join(LOGO, f"portussim_mark_{size}.png")
return Image.open(p).convert("RGBA") if os.path.exists(p) else None
def make_ico():
"""Windows .ico - multi-resolution, embeds 16-256px."""
base = _load(256) or _load(512)
if base is None:
print("[!] no source PNG found for .ico"); return
out = os.path.join(LOGO, "PortusSIM.ico")
sizes = [(16, 16), (24, 24), (32, 32), (48, 48), (64, 64),
(128, 128), (256, 256)]
base.save(out, format="ICO", sizes=sizes)
print(f"[ok] wrote {out}")
def make_icns():
"""macOS .icns via Pillow (good enough for PyInstaller bundling)."""
base = _load(512) or _load(256)
if base is None:
print("[!] no source PNG found for .icns"); return
out = os.path.join(LOGO, "PortusSIM.icns")
try:
base.save(out, format="ICNS")
print(f"[ok] wrote {out}")
except Exception as e:
print(f"[!] Pillow could not write .icns ({e}).")
print(" On macOS, generate it natively instead - see build_mac.sh.")
if __name__ == "__main__":
make_ico()
make_icns()