Skip to content

Instantly share code, notes, and snippets.

@rougeth
Last active May 14, 2022
Embed
What would you like to do?
Script para gerar os certificados da Python Brasil
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment