-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
56 lines (42 loc) · 1.58 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from PIL import Image, ImageDraw, ImageFont, ImageOps
import sys
safe_guide = 270
margin = 140
volunteer = 150
date = volunteer + 70
name_pos = 700
job_pos = name_pos + margin
location_pos = job_pos + margin
logo_w = int(814 * 2/3)
logo_h = int(178 * 2/3)
location = "Northern Ireland"
gen_list = [
{
"Name": "Ms. Vasuki Gnana Jothi",
"Title": "Ophthalmic Surgeon"
},
]
def IDCardGen(image, name, job, location):
# Create Canva
card = Image.open("backgrounds/" + image)
d = ImageDraw.Draw(card)
# Setup Fonts
font_semib = ImageFont.truetype("assets/fonts/JosefinSans-SemiBold.ttf", 125)
font = ImageFont.truetype("assets/fonts/JosefinSans-Light.ttf", 110)
font1 = ImageFont.truetype("assets/fonts/JosefinSans-Regular.ttf", 60)
# Loading Logo Image & Size
logo = Image.open("assets/logo.png")
logo = logo.resize((logo_w, logo_h))
# Top Corner
d.text((safe_guide, volunteer), "VOLUNTEER", font=font1, fill=("#fff"))
d.text((safe_guide, date), "6 - 11 FEB '23", font=font1, fill=("#fff"))
# Name & Position
d.text((safe_guide, name_pos), name.upper(), font=font_semib, fill=("#1A3E74"))
d.text((safe_guide, job_pos), job.upper(), font=font, fill=("#f6f6f6"), strokeWidth=100)
d.text((safe_guide, location_pos), location.upper(), font=font1, fill=("#1A3E74"))
# Logo
card.paste(logo, (safe_guide, 1700), logo)
# Exports
card.save("exports/" + name + ".jpg")
for i in gen_list:
IDCardGen((i["Name"]+".jpg"), i["Name"], i["Title"], location)