Python PIL图片添加字体
2017-08-28 15:34
323 查看
效果
左边原图,右面添加字体后保存的图。代码
# -*- coding: utf-8 -*- import PIL.Image as Image import PIL.ImageColor as ImageColor import PIL.ImageDraw as ImageDraw import PIL.ImageFont as ImageFont """ author@:xuna python2.7 """ #设置字体(LiberationSans-Regular.ttf这是我ubuntu16.04自带的字体) font = ImageFont.truetype('LiberationSans-Regular.ttf', 60) #打开图片 imageFile = "/home/xuna/桌面/笔记/1.jpg" im1=Image.open(imageFile) # 在图片上添加文字 1 draw = ImageDraw.Draw(im1) # (0,0):坐标 "XUNALOVE":添加的字体 (0,0,255):字体颜色 font:字体大小 draw.text((0, 0),"XUNALOVE",(0,0,255),font=font) draw = ImageDraw.Draw(im1) # 保存 im1.save("/home/xuna/桌面/笔记/res.png")
相关文章推荐
- python使用PIL给图片添加文字生成海报示例
- Python PIL 图片添加水印
- Python PIL 图片水印添加
- 利用python pil 实现给图片上添加文字
- 一套pdf水印处理软件,支持转图片,转文字,添加图片水印,文字水印,设置水印图片,设置字体
- 用 Python 的 PIL 模块为头像添加“未读消息”提示
- win7环境下python PIL Image模块 show函数不能正常显示图片
- python使用PIL模块实现给图片打水印的方法
- win 7 下 PIL python Image模块 show函数不能正常显示图片
- Python 利用PIL将图片转为字符
- python引入PIL做验证码,发现字体不支持的解决办法
- 用python简单处理图片(3):添加水印
- UILable添加超链接图片改变字体 NIAttributedLabel
- python中使用PIL制作并验证图片验证码
- Python 窗体美化,背景图片,字体样式
- fedora16为grub2添加、修改背景图片和字体颜色
- python处理图片之PIL模块简单使用方法
- Linux上安装Python的PIL和Pillow库处理图片的实例教程
- 用python简单处理图片(3):添加水印
- Python-----PIL Image模块 show函数不能正常显示图片