mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-06-18 23:42:37 +00:00
[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:
19
python/modules/rest-api/image_gen.py
Normal file
19
python/modules/rest-api/image_gen.py
Normal 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)
|
||||
Reference in New Issue
Block a user