Skip to content

Commit 62bdf04

Browse files
committed
commit 0010.py
1 parent 2a9c64d commit 62bdf04

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

mio4kon/0010/0010.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
11

2+
from PIL import Image, ImageDraw, ImageFont, ImageFilter
3+
import random
4+
verificationCode = ['K', 'L', 'K', 'B']
5+
6+
7+
def rndColor():
8+
return (random.randint(64, 255), random.randint(64, 255),
9+
random.randint(64, 255))
10+
11+
12+
def rndColor2():
13+
return (random.randint(32, 127), random.randint(32, 127),
14+
random.randint(32, 127))
15+
16+
17+
width = 60 * 4
18+
height = 60
19+
image = Image.new('RGB', (width, height), (255, 255, 255))
20+
font = ImageFont.truetype('Arial.ttf', 36)
21+
draw = ImageDraw.Draw(image)
22+
23+
# 背景
24+
for x in range(width):
25+
for y in range(height):
26+
draw.point((x, y), fill=rndColor())
27+
28+
# 文字
29+
for k in range(4):
30+
draw.text((60 * k + 10, 10), verificationCode[k], font=font, fill=rndColor2())
31+
32+
# 模糊
33+
34+
image = image.filter(ImageFilter.BLUR)
35+
image.save('code.jpg', 'jpeg')

mio4kon/0010/code.jpg

4.49 KB
Loading

0 commit comments

Comments
 (0)