2026-03-30 07:59:11 +02:00
|
|
|
"""Convert logo.png into a multi-size app.ico for the app, taskbar, and installer."""
|
2026-03-25 14:14:07 +01:00
|
|
|
import os
|
2026-03-30 07:59:11 +02:00
|
|
|
from PIL import Image
|
2026-03-25 22:03:39 +01:00
|
|
|
|
|
|
|
|
|
2026-03-25 14:14:07 +01:00
|
|
|
def create_icon():
|
2026-03-30 07:59:11 +02:00
|
|
|
base = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
src = os.path.join(base, "logo.png")
|
|
|
|
|
dst = os.path.join(base, "app.ico")
|
2026-03-25 22:03:39 +01:00
|
|
|
|
2026-03-30 07:59:11 +02:00
|
|
|
if not os.path.exists(src):
|
|
|
|
|
raise FileNotFoundError(f"logo.png not found in {base}")
|
2026-03-25 22:03:39 +01:00
|
|
|
|
2026-03-30 07:59:11 +02:00
|
|
|
img = Image.open(src).convert("RGBA")
|
2026-03-25 22:03:39 +01:00
|
|
|
|
2026-03-30 07:59:11 +02:00
|
|
|
sizes = [16, 24, 32, 48, 64, 128, 256]
|
|
|
|
|
frames = []
|
|
|
|
|
for s in sizes:
|
|
|
|
|
resized = img.resize((s, s), Image.LANCZOS)
|
|
|
|
|
frames.append(resized)
|
2026-03-25 14:14:07 +01:00
|
|
|
|
2026-03-30 07:59:11 +02:00
|
|
|
frames[0].save(
|
|
|
|
|
dst, format="ICO",
|
|
|
|
|
sizes=[(s, s) for s in sizes],
|
|
|
|
|
append_images=frames[1:],
|
|
|
|
|
)
|
|
|
|
|
print(f"app.ico created from logo.png ({len(sizes)} sizes)")
|
2026-03-25 14:14:07 +01:00
|
|
|
|
|
|
|
|
|
2026-03-30 07:59:11 +02:00
|
|
|
if __name__ == "__main__":
|
2026-03-25 14:14:07 +01:00
|
|
|
create_icon()
|