w = 60 * 4;
h = 60
# 创建一张图片,指定图片mode,长宽
image = Image.new('RGB', (w, h), (255, 255, 255))
# 设置字体类型及大小
font = ImageFont.truetype(font='arial.ttf', size=36)
# 创建Draw对象
draw = ImageDraw.Draw(image)
# 遍历给图片的每个像素点着色
for x in range(w):
for y in range(h):
draw.point((x, y), fill=randomBgColor())
# 将随机生成的chr,draw如image
for t in range(4):
draw.text((60 * t + 10, 10), randomChar(), font=font, fill=randomTextColor())