32 lines
817 B
Python
32 lines
817 B
Python
|
|
"""Convert logo.png into a multi-size app.ico for the app, taskbar, and installer."""
|
||
|
|
import os
|
||
|
|
from PIL import Image
|
||
|
|
|
||
|
|
|
||
|
|
def create_icon():
|
||
|
|
base = os.path.dirname(os.path.abspath(__file__))
|
||
|
|
src = os.path.join(base, "logo.png")
|
||
|
|
dst = os.path.join(base, "app.ico")
|
||
|
|
|
||
|
|
if not os.path.exists(src):
|
||
|
|
raise FileNotFoundError(f"logo.png not found in {base}")
|
||
|
|
|
||
|
|
img = Image.open(src).convert("RGBA")
|
||
|
|
|
||
|
|
sizes = [16, 24, 32, 48, 64, 128, 256]
|
||
|
|
frames = []
|
||
|
|
for s in sizes:
|
||
|
|
resized = img.resize((s, s), Image.LANCZOS)
|
||
|
|
frames.append(resized)
|
||
|
|
|
||
|
|
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)")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
create_icon()
|