-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
76 lines (60 loc) · 1.7 KB
/
main.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
73
74
75
76
import os
from PIL import Image
import numpy as np
spacing = 50
def pasteLetter( opArray,blnk, letter, letterType):
global spacing,xoffset
top=0;
bottom=0;
if letterType==1:
top = opArray[0]*spacing;
bottom = opArray[2]*spacing;
elif letterType==2:
top = opArray[1]*spacing;
bottom = opArray[2]*spacing;
elif letterType==3:
top = opArray[1]*spacing;
bottom = opArray[3]*spacing;
elif letterType==4:
top = opArray[0]*spacing;
bottom = opArray[3]*spacing;
ht = bottom - top;
xdim,ydim = letter.size
letter = letter.resize((int((xdim/ydim)*ht),ht))
xdim,ydim = letter.size
for i in range(xdim):
for j in range(ydim):
pixel = letter.getpixel((i,j))
if(pixel[0]<150):
blnk.putpixel((i+xoffset,j+top),pixel)
xoffset+=xdim
lst = os.listdir("/root/Documents/testing")
blnk = Image.open("/root/Documents/testing/Blank.jpg")
blnk=blnk.resize((2000,2828))
# lines = []
# for i in range(2828):
# if(i%spacing==0):
# lines.append(i)
dic={}
ls= os.listdir("/root/TypeNwrite/profiles/Priyansha_ki_writing/")
for item in ls:
img = Image.open("/root/TypeNwrite/profiles/Priyansha_ki_writing/"+item)
item.replace(".jpg","")
item.replace(".png","")
dic[item[0]]=(img,item[1])
s = """Hello my name is Lakhan
Mera naam hai lakhan
I dont like injection
fuck this shit"""
opArray = [0,1,2,3]
xoffset = 10
for ch in s:
if(ch==' '):
xoffset+=50
elif(ch=='\n'):
xoffset=10
opArray= [item + 5 for item in opArray]
else:
pasteLetter(opArray,blnk,dic[ch][0],int(dic[ch][1]))
blnk.save("test_sample.jpg")
blnk.show();