#!/usr/bin/env python3
"""
Generiert PWA Icons in verschiedenen Größen aus SVG
Benötigt: pip install cairosvg pillow
"""

import os
from PIL import Image
import io
import cairosvg

# Icon-Größen für PWA
sizes = [48, 72, 96, 128, 144, 152, 192, 384, 512]

# SVG-Datei einlesen
svg_path = 'task.svg'
with open(svg_path, 'r') as f:
    svg_data = f.read()

# Icons generieren
for size in sizes:
    # SVG zu PNG konvertieren
    png_data = cairosvg.svg2png(
        bytestring=svg_data.encode('utf-8'),
        output_width=size,
        output_height=size
    )
    
    # PNG speichern
    img = Image.open(io.BytesIO(png_data))
    img.save(f'icon-{size}x{size}.png', 'PNG')
    print(f'Erstellt: icon-{size}x{size}.png')

# Zusätzliche Icons für Shortcuts
shortcuts = [
    ('add-task', '''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" fill="none">
      <rect width="96" height="96" rx="16" fill="#000000"/>
      <path d="M48 32v32M32 48h32" stroke="#00D4FF" stroke-width="6" stroke-linecap="round"/>
    </svg>'''),
    ('calendar', '''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" fill="none">
      <rect width="96" height="96" rx="16" fill="#000000"/>
      <rect x="20" y="28" width="56" height="48" rx="4" stroke="#00D4FF" stroke-width="4" fill="none"/>
      <path d="M32 20v16M64 20v16M20 44h56" stroke="#00D4FF" stroke-width="4" stroke-linecap="round"/>
    </svg>''')
]

for name, svg in shortcuts:
    png_data = cairosvg.svg2png(
        bytestring=svg.encode('utf-8'),
        output_width=96,
        output_height=96
    )
    img = Image.open(io.BytesIO(png_data))
    img.save(f'{name}-96x96.png', 'PNG')
    print(f'Erstellt: {name}-96x96.png')

print('\nAlle Icons wurden erfolgreich generiert!')