-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy path10.py
More file actions
33 lines (24 loc) · 965 Bytes
/
10.py
File metadata and controls
33 lines (24 loc) · 965 Bytes
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 PIL import Image, ImageFont, ImageDraw, ImageFilter
import string
import random
def make_rand_char():
return random.choice(string.ascii_letters)
def generator_bgcolor():
return (random.randint(32, 125), random.randint(64, 255), random.randint(64, 255))
def generator_font_color():
return (random.randint(32, 120), random.randint(32, 127), random.randint(32, 127))
def producer():
width = 60*4
height = 60
image = Image.new('RGB', (width, height), (255, 255, 255))
font = ImageFont.truetype('arial.ttf', 36)
draw = ImageDraw.Draw(image)
for x in range(width):
for y in range(height):
draw.point((x, y), fill=generator_bgcolor())
for i in range(4):
draw.text((i*60+10, 10), make_rand_char(), font=font, fill=generator_font_color())
image = image.filter(ImageFilter.BLUR)
image.save('code.jpg', 'jpeg')
if __name__ == '__main__':
producer()