-
Notifications
You must be signed in to change notification settings - Fork 0
/
short.py
50 lines (40 loc) · 1.14 KB
/
short.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
import sys
import textwrap
import uuid
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
print("Enter/Paste your Kavithai. Ctrl-D ( windows ) to save it.")
contents = []
LINE = ""
QUOTES = ""
filename = str(uuid.uuid4())
while True:
try:
LINE = input()
except (SyntaxError, ValueError):
print("Empty Input or Wrong Input Value")
except KeyboardInterrupt:
print("Ok ok, quitting")
sys.exit(1)
except EOFError:
break
contents.append(LINE)
IMG = Image.open("images/quotes.png")
TEXT = "\n".join(contents)
SPACING = 30
wrapper = textwrap.TextWrapper(width=34)
word_list = wrapper.wrap(text=TEXT)
if word_list:
for ii in word_list[:-1]:
QUOTES = QUOTES + ii + "\n"
QUOTES += word_list[-1]
I1 = ImageDraw.Draw(IMG)
COLOR = "rgb(0, 0, 0)"
myFont = ImageFont.truetype("font/baloo.ttf", 36)
I1.text((195, 480), QUOTES, spacing=SPACING, font=myFont, fill=COLOR)
I1.text((442, 1000), "#tamilsms", fill = COLOR, font=myFont)
IMG.save(filename + ".png")
print("image Generated : " + filename + ".png")
else:
print("Empty Kavithai Data")