-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpillow_test2.py
More file actions
44 lines (26 loc) · 911 Bytes
/
pillow_test2.py
File metadata and controls
44 lines (26 loc) · 911 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
34
35
36
37
38
39
40
41
42
from PIL import Image, ImageDraw, ImageFont, ImageFilter
import random
def rndStr():
str=''
chars= 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'
length=len(chars)-1
return chars[(random.randint(0,length))]
def rndColor():
return (random.randint(64,255),random.randint(64,255),random.randint(64,255))
def rndColor2():
return (random.randint(32,127),random.randint(32,127),random.randint(32,127))
#width = 60 * 4
#height = 60
width = 32 * 4
height = 60
im=Image.new('RGB',(width,height),(255,255,255))
font = ImageFont.truetype('C:\Windows\Fonts\Arial.ttf',36)
draw = ImageDraw.Draw(im)
for x in range(width):
for y in range(height):
draw.point((x,y),fill=rndColor())
for t in range(4):
draw.text((30*t + 10, 10), rndStr(), font=font, fill=rndColor2())
#im.filter(ImageFilter.GaussianBlur(0.5)).show()
im=im.filter(ImageFilter.GaussianBlur(0.5))
im.save('code.png')