Backend sketch

master
edne 2018-03-10 02:23:48 +01:00 committed by subnixr
parent 3fb6bc40aa
commit 0c89e4ee8d
2 changed files with 26 additions and 0 deletions

BIN
Verdana.ttf 100644

Binary file not shown.

26
caption.py 100755
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
img = Image.open("input.jpg")
img.thumbnail((500, 500), Image.ANTIALIAS)
margin = 30
font_size = 24
font_file = 'Verdana.ttf'
w0, h0 = img.size
w1, h1 = 2*margin + w0, 2*margin + h0 + 30
out_img = Image.new('RGB', size=(w1, h1), color=(255, 255, 255))
out_img.paste(img, (margin, margin + 30))
font = ImageFont.load_default().font
font = ImageFont.truetype(font_file, font_size)
draw = ImageDraw.Draw(out_img)
draw.text((margin, margin/2), 'Antani', (0, 0, 0), font=font)
out_img.save('output.jpg')