图标消息提示效果
2016-02-23 12:59
531 查看
做出类似微信消息动态提示的效果
以QQ图标为素材进行处理
需要用到Python的PIL库
这是素材
这个是处理后的图片:
大功告成
Python练手链接,大家可以看看
以QQ图标为素材进行处理
需要用到Python的PIL库
from PIL import Image,ImageFilter,ImageFont,ImageDraw im=Image.open(r'C:\Users\sunqi\Desktop\00.png') front_path = r'C:\Windows\Fonts\Arial.ttf' imgcolor=(255,67,30) font = ImageFont.truetype(front_path, 12) # 图片字体 print(dir(im)) print(im.size) width,height=im.size #获取图像的尺寸 r=8 #设置圆的半径 cw,ch=pos=(46,9) draw=ImageDraw.Draw(im) bbox=(cw-r,ch-r,cw+r,ch+r) draw.ellipse(bbox,fill=imgcolor) num='15' draw.text((cw-4-3.5*(len(num)-1),ch-6),num,font=font,fill='white') print(font.getsize('15')) im.show() im.save(r'C:\Users\sunqi\Desktop\01.png')
这是素材
这个是处理后的图片:
大功告成
Python练手链接,大家可以看看
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法