Skip to content
Merged

add #207

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions mio4kon/0000/0000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from PIL import Image, ImageDraw, ImageFont, ImageFilter
import sys, os, random

num = str(random.randint(1, 99))
imagePath = os.path.join(sys.path[0], 'mio.jpg')
savaPath = os.path.join(sys.path[0], 'mio_dot.jpg')


def add_num(im, wDraw, hDraw):
font = ImageFont.truetype('Arial.ttf', 30)
draw = ImageDraw.Draw(im)
draw.ellipse(
(radioX, radioY, radioX + 30, radioY + 30), fill='red', outline='red')
draw.text((wDraw, hDraw), num, font=font, fill='white')
im.save(savaPath, 'jpeg')


if __name__ == '__main__':
im = Image.open(imagePath)
w, h = im.size
print('Original image size: %sx%s' % (w, h))
wDraw = int(0.8 * w)
hDraw = int(0.01 * h)
radioX = wDraw
radioY = hDraw
print('radioX:', radioX)
print('radioY:', radioY)
add_num(im, wDraw, hDraw)
Binary file added mio4kon/0000/mio.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mio4kon/0000/mio_dot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions mio4kon/0010/0010.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

from PIL import Image, ImageDraw, ImageFont, ImageFilter
import random
verificationCode = ['K', 'L', 'K', 'B']


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
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=rndColor())

# 文字
for k in range(4):
draw.text((60 * k + 10, 10), verificationCode[k], font=font, fill=rndColor2())

# 模糊

image = image.filter(ImageFilter.BLUR)
image.save('code.jpg', 'jpeg')
Binary file added mio4kon/0010/code.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.