mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-01-14 04:18:22 +00:00
restructuring and splitting image generation into multiple files adding doge sun image generation
20 lines
608 B
Python
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)
|