Skip to content

Instantly share code, notes, and snippets.

@rougeth
Last active May 14, 2022 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rougeth/40c7717a8c982869cd9c210d8bebb64a to your computer and use it in GitHub Desktop.
Save rougeth/40c7717a8c982869cd9c210d8bebb64a to your computer and use it in GitHub Desktop.
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