Files
Sissi/python/modules/rest-api/image_gen.py
Sheldan 81824db1f1 [SIS-xxx] adding html wrapper for debra images
restructuring and splitting image generation into multiple files
adding doge sun image generation
2023-11-29 00:04:29 +01:00

20 lines
608 B
Python

from __main__ import app
from PIL import Image, ImageDraw, ImageFont
from flask import request
from utils import serve_pil_image
@app.route('/memes/doge/orangeSun/')
def image_gen():
text = request.args.get('text')
with Image.open('res/img/semf_template.jpg') as im:
d1 = ImageDraw.Draw(im)
text_box_size = (300, 240)
W, H = text_box_size
font = ImageFont.truetype(f'Impact.ttf', 60)
_, _, w, h = d1.textbbox((0, 0), text, font=font)
d1.text(((W-w)/2 + 320, (H-h)/2 + 120), text, font=font, fill=(255, 255, 255))
return serve_pil_image(im)