-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbob.py
33 lines (31 loc) · 1.02 KB
/
bob.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
from random import randint
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import datetime
import os
inp = input('Enter text: ')
def transform(strt):
splitter = list(strt)
suffix = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
if os.path.exists('/out'):
print("True")
try:
os.makedirs('/out')
except OSError as exception:
print("directory could not be created, please manually make a folder called 'out' in your current directory")
for i in range(len(splitter)):
x = randint(0,1)
if (x == 1):
if (not splitter[i].isupper()):
splitter[i] = splitter[i].upper()
x = "".join(splitter)
img = Image.open("img/bob.jpg")
font = ImageFont.truetype("fonts/HelveticaNeueLt.ttf", 20)
draw = ImageDraw.Draw(img)
draw.text((20,10), x, (0,0,0), font=font)
draw = ImageDraw.Draw(img)
file_name = "out/{}.jpg".format(suffix)
img.save(file_name)
Image.open(file_name).show()
transform(inp)