-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscript.py
55 lines (38 loc) · 1.29 KB
/
script.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
import re
import xlrd
from xlrd import open_workbook
from PIL import Image, ImageDraw, ImageFont
# Open the excel file for reading names in first column
book = xlrd.open_workbook("book1.xlsx")
sheet = book.sheet_by_index(0)
original_list = []
clean_list = []
for k in range(1, sheet.nrows):
original_list.append(str(sheet.row_values(k)))
print(original_list)
# Removing Special Character from the Data using Regex
# CleanString = re.sub('\W+'," ", "['Neel Kamath']" )
for i in original_list:
clean_string = re.sub('[^A-Za-z0-9]+', " ", i)
clean_list.insert(0, clean_string)
print(clean_list)
def hacker_name(name):
# create Image object with the input image
image = Image.open('certificate_raw.jpg')
# initialise the drawing context with the image object as background
draw = ImageDraw.Draw(image)
font = ImageFont.truetype('Roboto-Bold.ttf', size=100)
if len(j) < 12:
(x, y) = (2090, 1520)
elif len(j) < 20:
(x, y) = (1950, 1520)
else:
(x, y) = (1850, 1520)
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), name, fill=color, font=font)
image.save(name + ".jpg") # save the edited image
#image.save('optimized.png', optimize=True, quality=20)
for j in clean_list:
hacker_name(j)
print(len(j))
print(j)