c
from flask import Flask, request, send_file from PIL import Image, ImageDraw, ImageFont import os, zipfile, textwrap from datetime import datetime app = Flask(__name__) OUTPUT_DIR = "output" os.makedirs(OUTPUT_DIR, exist_ok=True) # TEXT IN CHUNKS AUFTEILEN def split_text(text, max_length=300): words = text.split() chunks = [] current = [] for word in words: current.append(word) if len(" ".join(current)) >= max_length: chunks.append(" ".join(current)) current = [] if current: chunks.append(" ".join(current)) return chunks # BILD ERZEUGEN def create_image(text, path): width, height = 1080, 1080 img = Image.new("RGB", (width, height), (15, 15, 15)) draw = ImageDraw.Draw(img) # Font (Fallback sicher) try: font = ImageFont.truetype("arial.ttf", 55) except: font = ImageFont.load_default() wrapped = textwrap.fill(text, width=28) bbox = draw.multiline_textbbox((0, 0), wrapped, font=font) x = (width - (bbox[2] - bbox[0])) / 2 y = (height - (bbox[3] - bbox[1])) / 2 draw.multiline_text( (x, y), wrapped, fill=(255, 255, 255), font=font, align="center" ) img.save(path) # FRONTEND (IM SELBEN SCRIPT) HTML = """
Kommentare
Kommentar veröffentlichen