Feat: App-Icons für PWA hinzugefügt
This commit is contained in:
39
scripts/generate_icons.py
Normal file
39
scripts/generate_icons.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import os
|
||||
|
||||
def create_icon(size):
|
||||
# Erstelle ein neues Bild mit grünem Hintergrund
|
||||
image = Image.new('RGB', (size, size), '#4CAF50')
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Versuche, eine Schriftart zu laden
|
||||
try:
|
||||
font = ImageFont.truetype("arial.ttf", size // 3)
|
||||
except:
|
||||
font = ImageFont.load_default()
|
||||
|
||||
# Text "MEDI" zeichnen
|
||||
text = "MEDI"
|
||||
text_bbox = draw.textbbox((0, 0), text, font=font)
|
||||
text_width = text_bbox[2] - text_bbox[0]
|
||||
text_height = text_bbox[3] - text_bbox[1]
|
||||
x = (size - text_width) // 2
|
||||
y = (size - text_height) // 2
|
||||
draw.text((x, y), text, fill='white', font=font)
|
||||
|
||||
# Speichere das Icon
|
||||
output_file = f'static/images/icon-{size}x{size}.png'
|
||||
image.save(output_file, 'PNG')
|
||||
print(f'Icon {size}x{size} generiert: {output_file}')
|
||||
|
||||
def main():
|
||||
# Erstelle das Verzeichnis, falls es nicht existiert
|
||||
os.makedirs('static/images', exist_ok=True)
|
||||
|
||||
# Generiere Icons in verschiedenen Größen
|
||||
sizes = [192, 512]
|
||||
for size in sizes:
|
||||
create_icon(size)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user