-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNo.10_py.py
More file actions
25 lines (21 loc) · 784 Bytes
/
No.10_py.py
File metadata and controls
25 lines (21 loc) · 784 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
# -*- coding: utf-8 -*-
from PIL import Image,ImageDraw,ImageFont,ImageFilter
import random
def rndfont():
return chr(random.randint(65, 90))
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))
wight = 60 * 4
high = 60
image = Image.new('RGB', (wight, high), (255, 255, 255))
font = ImageFont.truetype('arial.ttf', 36)
draw = ImageDraw.Draw(image)
for x in range(wight):
for y in range(high):
draw.point((x,y), fill=rndcolor())
for i in range(4):
draw.text((60*i+10, 10), rndfont(), font=font, fill=rndcolor2())
image = image.filter(ImageFilter.BLUR)
image.save('code.jpg', 'jpeg')