-
Notifications
You must be signed in to change notification settings - Fork 0
/
certiGen.py
76 lines (57 loc) · 1.87 KB
/
certiGen.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from PIL import Image, ImageDraw, ImageFont
import qrcode
def createCertificate(name, id, sign):
# Open the image
image = Image.open("templates/temp.jpg")
# Initialize the drawing context
draw = ImageDraw.Draw(image)
# Choose a font and size
'''
This part will define the Name characteristics
'''
Namefont = ImageFont.truetype("font/static/Alkatra-Regular.ttf", size=40)
# Choose the position and color for the text
Name_position = (690, 550)
# 690, 550 for Soham De
Name_color = (0, 0, 0) # White color in RGB format
# Text to write on the image
Name = name
'''
This part below defines the characteristics of the Unique ID
'''
id_position = (342,850)
UniqueId = id
idfont = ImageFont.truetype("arial.ttf", size=30)
'''
This part below defines the characteristics of the Signature
'''
sign_position = (685,810)
signature = sign
signfont = ImageFont.truetype("arial.ttf", size=35)
'''
This part below defines the characteristics of the Qr-Code
'''
data = 'id'
# Encoding data using make() function
qr_img = qrcode.make(data)
# Draw the text on the image
draw.text(Name_position, Name, fill=Name_color, font=Namefont)
draw.text(id_position, UniqueId, fill=Name_color, font=idfont)
draw.text(sign_position, signature, fill=Name_color, font=signfont)
#imagepaste
Image2 = qr_img
Image2copy = Image2.copy()
Image2copy = Image2copy.resize((150, 150))
# paste image giving dimensions
image.paste(Image2copy, (1185, 760))
# Save or display the modified image
image.save(f'certificate/{Name}_{UniqueId}.jpg')
return image
"""
testing
"""
name = input("Enter name: ")
id = input('Enter your unique Id:')
sign = input("Enter sign: ")
createCertificate(name , id, sign )
print("your certificate has been generated! ")