feat: add favicon generator and Pyodide profile sync integration

This commit is contained in:
John Doe
2025-10-17 22:47:13 +02:00
parent 47028c95ae
commit 3812d36cd6
4 changed files with 1109 additions and 22 deletions
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Create a favicon.ico from an existing PNG asset.
Usage: python tools/create_favicon.py
Produces: ./favicon.ico
The script will try to import Pillow. If it's not available, it prints instructions.
"""
import os
import sys
ROOT = os.path.dirname(os.path.dirname(__file__))
SRC = os.path.join(ROOT, 'assets', 'BMP_WEWIN.png')
# fallback to assets/Rat/BMP_WEWIN.png if present
if not os.path.exists(SRC):
alt = os.path.join(ROOT, 'assets', 'Rat', 'BMP_WEWIN.png')
if os.path.exists(alt):
SRC = alt
OUT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'favicon.ico')
def ensure_pillow():
try:
from PIL import Image
return Image
except Exception:
print('Pillow (PIL) is required to run this script. Install with:')
print(' pip install Pillow')
return None
def create_favicon():
Image = ensure_pillow()
if Image is None:
return 2
if not os.path.exists(SRC):
print(f'Source PNG not found: {SRC}')
return 1
try:
img = Image.open(SRC)
# Create multiple sizes for favicon
sizes = [(16, 16), (32, 32), (48, 48), (64, 64)]
icons = [img.resize(s, Image.Resampling.LANCZOS) if hasattr(Image, 'Resampling') else img.resize(s) for s in sizes]
# Save as ICO
icons[0].save(OUT, format='ICO', sizes=sizes)
print(f'Created favicon: {OUT}')
return 0
except Exception as e:
print('Failed to create favicon:', e)
return 3
if __name__ == '__main__':
sys.exit(create_favicon())