39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
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() |