[SIS-xxx] adding html wrapper for debra images

restructuring and splitting image generation into multiple files
adding doge sun image generation
This commit is contained in:
Sheldan
2023-11-29 00:04:29 +01:00
parent 0390d7c8ca
commit 81824db1f1
7 changed files with 269 additions and 215 deletions

View File

@@ -0,0 +1,19 @@
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)