Fonte: https://www.fontsquirrel.com/fonts/vt323
$ pip install pillow python-slugify
$ python pybr_certs.py nomes.txt
Fork do https://github.com/GabrielRF/EstudeiEmHarvardBot
Fonte: https://www.fontsquirrel.com/fonts/vt323
$ pip install pillow python-slugify
$ python pybr_certs.py nomes.txt
Fork do https://github.com/GabrielRF/EstudeiEmHarvardBot
Nome da pessoa 1 | |
Nome da pessoa 2 | |
Nome da pessoa 3 | |
... |
import sys | |
from PIL import Image | |
from PIL import ImageFont | |
from PIL import ImageDraw | |
from slugify import slugify | |
def generate_certificate(name): | |
img = Image.open("template.jpg") | |
draw = ImageDraw.Draw(img) | |
name_color = (26, 213, 195) | |
name_font = ImageFont.truetype("VT323.ttf", 90) | |
name_width, name_height = draw.textsize(name, font=name_font) | |
template_width = 1056 | |
template_height = 816 | |
draw.text( | |
((template_width-name_width)/2, template_height/1.9), | |
name, | |
name_color, | |
font=name_font, | |
) | |
img.save(f"{slugify(name)}.jpg") | |
if __name__ == "__main__": | |
filename = sys.argv[1] | |
with open(filename) as fp: | |
for name in fp.readlines(): | |
generate_certificate(name) |