Created
September 12, 2023 16:57
-
-
Save Shaam-K/b0f25abc14a268c9c49c1a4879dfabf9 to your computer and use it in GitHub Desktop.
certificate name filler generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the PIL library | |
| from PIL import Image | |
| from PIL import ImageDraw | |
| from PIL import ImageFont | |
| import csv | |
| csv_file_path = 'names.csv' | |
| with open(csv_file_path, 'r') as file: | |
| csv_reader = csv.reader(file) | |
| data_list = [] | |
| for row in csv_reader: | |
| data_list += row | |
| print(len(data_list)) # check this number with no of names present is same as name list | |
| for name in data_list: | |
| # Open an Ima | |
| img = Image.open('certificate.jpg') | |
| # Call draw Method to add 2D graphics in an image | |
| I1 = ImageDraw.Draw(img) | |
| # Custom font style and font size | |
| myFont = ImageFont.truetype('font.ttf', 65) # specify font | |
| # Add Text to an image | |
| I1.text((800, 675), name.title(), font=myFont, fill =(123, 76, 4),anchor='ms') | |
| # 800, 675 are x and y coordinates (i think), fill takes rgb value | |
| img.save(f'certificates_cyber_event/{name.upper()}.jpg', 'JPEG') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment