Skip to content

Commit 10242d1

Browse files
authored
Merge pull request #167 from souraOP/souraOP
Added Certificate generator using python under C folder
2 parents fd8bae7 + 7a4f889 commit 10242d1

File tree

7 files changed

+61
-0
lines changed

7 files changed

+61
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

C/.DS_Store

10 KB
Binary file not shown.

C/certificate-generator/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generate Certificates with ease using Python!
2+
3+
## Important!
4+
5+
### Make sure you have this 3 files along with the python in folder!
6+
- Certificate Template in png or jpeg format.
7+
- Excel Sheet containing the data of Name and their College (College taken as example could be any other details)
8+
- A font of your choice having format .ttf or .otf
9+
- And ofcourse your .py python code :)
10+
11+
12+
### Step 1
13+
14+
- First get your excel sheet with all the data loaded
15+
- Make sure that your excel sheet should have a "Name" and "College" Column Name (College taken as example it can be anything)
16+
17+
### Step 2
18+
19+
- Make sure that you have the certificate and font downloaded and are in the same folder!
20+
21+
### Step 3
22+
23+
- In your certificate.py code
24+
- According to your certficate template change the ``` name_X ``` and ```name_y``` variable values in the python to change the position of name text.
25+
- ```name_x``` refers to the change in position of Name in the X axis i.e., Horizontal Movement
26+
- ```name_y``` referes to the change in position of Name in the Y axis i.e., Vertical Movement
27+
- This is a trial and error method. So keep trying different values so that it ultimately fits in the name portion
28+
29+
30+
### Step 4
31+
32+
- Now just the run the certificate.py in the same folder
33+
- You will see the certificates keep on generating :)
34+
- Have Fun
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#Sourasish Certificate Generator
2+
import pandas as pd
3+
from PIL import Image, ImageDraw, ImageFont
4+
5+
df = pd.read_excel('names.xlsx')
6+
7+
img = Image.open('certificate_template.png')
8+
9+
nameFont = ImageFont.truetype('fontss.ttf', 110)
10+
11+
color = (0, 0, 0) # black
12+
13+
for index, row in df.iterrows():
14+
Name = row['name']
15+
College = row['college']
16+
17+
cert = Image.new('RGB', img.size, (255, 255, 255))
18+
19+
cert.paste(img, (0, 0))
20+
21+
draw = ImageDraw.Draw(cert)
22+
name_x, name_y = 1200, 940
23+
stream_x, stream_y = 900, 1030
24+
draw.text((name_x, name_y), Name, font=nameFont, fill=color, anchor='mm')
25+
draw.text((stream_x, stream_y), College, font=nameFont, fill=color, anchor='mm')
26+
27+
cert.save(f'{Name}_certificate.png')
1.63 MB
Loading

C/certificate-generator/fontss.ttf

30.7 KB
Binary file not shown.

C/certificate-generator/names.xlsx

8.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)