PIL修改图片

来源:互联网 发布:找工作可靠的软件 编辑:程序博客网 时间:2024/06/14 06:19
#-*- coding: utf-8 -*-from PIL import Image,ImageDraw,ImageFont,ImageFilterimport randomrandomNum = str(random.randint(1,99))image = Image.open('/path_to/2.jpeg')width,height = image.sizewDraw = 0.8 * widthhDraw = 0.08 * heightfont = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',30)draw = ImageDraw.Draw(image)draw.text((wDraw,hDraw),randomNum,font=font,fill=(255,33,33))image.save('/path_to/2-1.jpeg','jpeg')image.show()
0 0