Python中pillow知识点学习
2018-04-30 12:57
681 查看
此系列意在记录于一些有趣的程序及对其的总结。
问题来源:
https://github.com/Yixiaohan/show-me-the-code
https://github.com/HT524/500LineorLess_CN
今天这个程序于一张图片中添加数字,类似于qq头像上的小红点,只不过这个是静态的。
首先使用的是pillow这个图像库。
总体思路是通过Image.open()打开图像,设置要绘制的信息的格式,ImageDraw.Draw()生成被修改的实例,再通过text()方法进行修改。
程序如下:
from PIL import Image, ImageDraw, ImageFont def pic_add_num(image): my_font = ImageFont.truetype(r"C:\windows\Fonts\simsun.ttc", size=40) color = "red" width, height = image.size position = (width-40, 0) draw = ImageDraw.Draw(image) draw.text(position, "99", font=my_font, fill=color) image.save("add_num.jpg") if __name__ == "__main__": img = Image.open("universe.jpg") pic_add_num(img)
您可能感兴趣的文章:
相关文章推荐
- python3学习笔记:零碎知识点
- python统计学习相关琐碎知识点
- python学习-知识点记录(Temp)
- Python 学习中,特别知识点记录
- 【Python爬虫学习笔记(3)】Beautiful Soup库相关知识点总结
- Python学习笔记(知识点学习链接)
- Python爬虫学习纪要(十二):BeautifulSoup相关知识点4
- Python学习第一周-知识点
- Python学习之pillow库入门
- python学习--核心编程4习题以及知识点记录
- python的学习知识点总结
- Python Django 学习知识点记录
- 【Python学习】 之 Python3.x(小知识点汇集)
- python学习知识点
- python初步学习知识点1
- Python爬虫学习纪要(二):BeautifulSoup相关知识点2
- python学习日记,易错知识点总结(1)
- 【Python爬虫学习笔记(2)】正则表达式(re模块)相关知识点总结
- python学习(仅作为个人学习笔记,记录零散知识点)
- python小知识点学习笔记