📊 Was das Tool macht
Aus einer CSV-Datei mit Vornamen werden vollautomatisch PNG-Designs in 9 Farbvarianten generiert. Jedes Bild ist exakt so groß wie der Text – kein Padding, transparent, mit Outline für beste Druckqualität.
CSV → PNG
Liest Vornamen aus
vornamen.csv und erzeugt pro Name 9 Farbvarianten – vollautomatisch.9 Farben
Rot, Blau, Grün, Gelb, Orange, Lila, Rosa, Schwarz, Weiß – mit schwarzem Outline für Kontrast.
Dynamische Größe
Bildgröße = exakte Textgröße via
textbbox(). Kein Padding, optimiert für Spreadshirt-Upload.Outline-Rendering
3px schwarzer Outline für alle Farben (außer Schwarz selbst) sorgt für Druckbarkeit auf jedem Untergrund.
💻 Echter Code aus dem Projekt
PNG-Erstellung mit PIL: dynamische Textgröße + Outline
#!/usr/bin/env python3
from PIL import Image, ImageDraw, ImageFont
COLORS = {
'rot': (255, 0, 0), 'blau': (0, 102, 255),
'gruen': (0, 170, 0), 'gelb': (255, 215, 0),
'orange': (255, 102, 0), 'lila': (153, 50, 204),
'rosa': (255, 105, 180), 'schwarz': (0, 0, 0),
'weiss': (255, 255, 255)
}
OUTLINE_WIDTH = 3
PADDING = 0 # Bildgröße = exakt Textgröße
def create_png(name, color_name, color_rgb, output_dir):
text = f"Geburtstagskind {name}"
font_size = 180
font = ImageFont.truetype('arial.ttf', font_size)
# Textgröße messen mit textbbox()
temp_img = Image.new('RGB', (1000, 1000))
temp_draw = ImageDraw.Draw(temp_img)
bbox = temp_draw.textbbox((0, 0), text, font=font)
left, top, right, bottom = bbox
img_width = right - left
img_height = bottom - top
# Transparentes Bild
img = Image.new('RGBA', (img_width, img_height), (0, 0, 0, 0))
draw = ImageDraw.Draw(img)
Outline-Zeichnung für Kontrast auf allen Untergründen
# Schwarzer Outline für alle Farben außer schwarz
if color_name != 'schwarz':
for adj_x in range(-OUTLINE_WIDTH, OUTLINE_WIDTH + 1):
for adj_y in range(-OUTLINE_WIDTH, OUTLINE_WIDTH + 1):
if adj_x != 0 or adj_y != 0:
draw.text((x + adj_x, y + adj_y), text,
font=font, fill=(0, 0, 0, 255))
# Text in Zielfarbe darüber
draw.text((x, y), text, font=font, fill=(*color_rgb, 255))
filename = f"{name}_{color_name}.png"
img.save(os.path.join(output_dir, filename), 'PNG')
Batch-Verarbeitung: CSV → N × 9 PNGs
def process_csv(csv_file, output_dir='designs'):
with open(csv_file, 'r', encoding='utf-8') as f:
reader = csv.reader(f)
names = [row[0].strip() for row in reader if row and row[0].strip()]
print(f"Erstelle {len(names)} x {len(COLORS)} = "
f"{len(names) * len(COLORS)} PNG-Dateien...")
for name in names:
safe_name = name.replace(' ', '_')
for color_name, color_rgb in COLORS.items():
create_png(safe_name, color_name, color_rgb, output_dir)
🎯 Business Value
Massenerstellung in Sekunden
100 Namen × 9 Farben = 900 Designs in unter einer Minute. Manuell wären das Stunden.
Spreadshirt-optimiert
Transparenter Hintergrund, exakte Textgröße, Outline – direkt uploadfähig ohne Nachbearbeitung.