Skip to content

Commit 038c2e1

Browse files
authored
Add files via upload
1 parent 2d2ac5f commit 038c2e1

File tree

8 files changed

+150
-0
lines changed

8 files changed

+150
-0
lines changed
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Certificate Gerneration Script
2+
3+
## Introduction
4+
5+
Generating a ton of certificates for any occassion is quite tedious if you're not familiar with the concept of automation. Well, you won't have to worry anymore because this script will do all the heavy lifting for you.
6+
7+
8+
## How to get started?
9+
10+
In order to run this script, you need to have Python 3.7.x installed in your machine. You can get it from [here](https://www.python.org/downloads/). After you're done installing Python 3.7.x, run the following command from your terminal to install [OpenCV](https://pypi.org/project/opencv-python/):
11+
12+
```
13+
pip install opencv-python
14+
```
15+
```
16+
Now in the namelist.txt file just add the name for whom you want to generate the certificate
17+
if you want different template add a template file as template.png in the same directory
18+
```
19+
20+
## Great, you're almost there!
21+
22+
23+
## Run the script
24+
25+
Open your terminal and navigate to the directory where you downloaded this project. After that, run the following command from your terminal to generate your certificates:
26+
27+
```
28+
python certificate.py
29+
```
30+
31+
![endpoint](https://github.com/Tejas1510/hacking-tools-scripts/blob/certificate/Python/Certificate_Generator/images/input1.png)
32+
33+
34+
## Yaay! Now you've successfully generated all your certificates and you can find them in the *Generated_Certificate* directory. Happy Coding! 💘
35+
36+
37+
![endpoint](https://github.com/Tejas1510/hacking-tools-scripts/blob/certificate/Python/Certificate_Generator/images/image1.png)
38+
39+
![endpoint](https://github.com/Tejas1510/hacking-tools-scripts/blob/certificate/Python/Certificate_Generator/images/image2.png)
40+
41+
42+
![built with love](https://forthebadge.com/images/badges/built-with-love.svg)
43+
44+
Check out my Github profile [Tejas1510!](https://github.com/Tejas1510)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
import cv2
3+
import os
4+
5+
# This text file contains the list of names of those for whom this
6+
# certificate is being generated SEPERATED BY A NEW LINE AND NO SPACES
7+
8+
input_txt_file = os.path.normpath('./namelist.txt')
9+
10+
# This is the main certificate template image which will be used to
11+
# generate all the certificates
12+
13+
template_image_path = \
14+
os.path.normpath('./template.png')
15+
16+
# Make sure this output directory already exists
17+
18+
output_directory_path = os.path.dirname('./Generated_Certificate/') \
19+
+ '/'
20+
21+
# Customize the font color and font size
22+
23+
font_size = 3.6
24+
font_color = (51, 51, 51)
25+
26+
# Y adjustment determines the px to position above the horizontal
27+
# center of the template (may be positive or negative)
28+
29+
coordinate_y_adjustment = -120
30+
31+
# X adjustment determiens the px to position to the right of verticial
32+
# center of the template (may be positive or negative)
33+
34+
coordinate_x_adjustment = 7
35+
36+
print('Ceritificate Generation Started ...')
37+
38+
with open(input_txt_file) as input_list:
39+
40+
content = input_list.read().splitlines()
41+
42+
for line in content:
43+
44+
certi_name = line
45+
46+
img = cv2.imread(template_image_path)
47+
48+
# Available Fonts in OpenCV:
49+
# Hershey Simplex: FONT_HERSHEY_SIMPLEX
50+
# Hershey Plain: FONT_HERSHEY_PLAIN
51+
# Hershey Duplex: FONT_HERSHEY_DUPLEX
52+
# Hershey Complex: FONT_HERSHEY_COMPLEX
53+
# Hershey Triplex: FONT_HERSHEY_TRIPLEX
54+
# Hershey Complex Small: FONT_HERSHEY_COMPLEX_SMALL
55+
# Hershey Script Simplex: FONT_HERSHEY_SCRIPT_SIMPLEX
56+
# Hershey Script Complex: FONT_HERSHEY_SCRIPT_COMPLEX
57+
58+
font = cv2.FONT_HERSHEY_SIMPLEX
59+
text = certi_name
60+
61+
textsize = cv2.getTextSize(text, font, font_size, 10)[0]
62+
text_x = (img.shape[1] - textsize[0]) / 2 \
63+
+ coordinate_x_adjustment
64+
text_y = (img.shape[0] + textsize[1]) / 2 \
65+
- coordinate_y_adjustment
66+
text_x = int(text_x)
67+
text_y = int(text_y)
68+
69+
cv2.putText(
70+
img,
71+
text,
72+
(text_x, text_y),
73+
font,
74+
font_size,
75+
font_color,
76+
10,
77+
)
78+
certi_path = output_directory_path + certi_name + '.png'
79+
cv2.imwrite(certi_path, img)
80+
81+
cv2.destroyAllWindows()
82+
83+
print(
84+
'''Ceritificate Generation Completed.
85+
Find your generated certificates in ''' + output_directory_path[2::]
86+
)
359 KB
Loading
69.9 KB
Loading
38.9 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
John Smith
2+
John Reese
3+
Steve Rogers
4+
Remy Danton
5+
Kristyn Woolridge
6+
Yu Schaber
7+
Eve Fears
8+
Stuart Moree
9+
Shaunta Eudy
10+
Renay Villalobos
11+
Constance Lavin
12+
Cyrus Miler
13+
Ophelia Palazzo
14+
Altha Monier
15+
Sonya Heisey
16+
Gabriel Blinn
17+
Latisha Nelms
18+
Terresa Wootton
19+
Hye Fenske
20+
Wilburn Roberts
127 KB
Loading

0 commit comments

Comments
 (0)