1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import random
from PIL import Image, ImageDraw, ImageFont, ImageFilter
width = 60 * 4 height = 60 image = Image.new('RGB', (width, height), (255, 255, 255)) font = ImageFont.truetype('C://Windows//Fonts//Arial.ttf', 36) draw = ImageDraw.Draw(image)
for x in range(width): for y in range(height): draw.point((x, y), fill=(random.randint(64, 255), random.randint(64, 255), random.randint(64, 255)))
for t in range(4): draw.text((60 * t + 10, 10), chr(random.randint(65, 90)), font=font, fill=(random.randint(32, 127), random.randint(32, 127), random.randint(32, 127)))
image = image.filter(ImageFilter.BLUR) image.save('C://Users//chenkaixin12121//Downloads//code.jpg', 'jpeg')
|