作业6:
在图像上显示数字,随机显示数字随机的位置,显示随机的数字,在固定位置显示随机数字,先别随机位置了。
http://www.cnhonkerarmy.com/thread-222522-1-1.html
https://blog.csdn.net/li827437709/article/details/80224073
https://www.jianshu.com/p/617184552cbc
https://blog.csdn.net/danation/article/details/76199442
注意字体设置部分
#-*-coding: utf-8-*-
from PIL import Image, ImageDraw, ImageFont
def imageWriter(filePath, number):
img = Image.open(filePath)
size = img.size
fontSize = size[1] / 4
draw = ImageDraw.Draw(img)
ttFont = ImageFont.truetype('C:/windows/fonts/ARLRDBD.TTF', 50)
draw.text((size[0]-fontSize, 0), str(number),fill=(255, 0, 0) ,font=ttFont)
img.show()
print(imageWriter('./Tomylove1.png', 8))