ImageDraw

例子 画出一个灰色的线

from PIL import Image, ImageDraw

im = Image.open("hopper.jpg")

draw = ImageDraw.Draw(im)
draw.line((0, 0) + im.size, fill=128)
draw.line((0, im.size[1], im.size[0], 0), fill=128)
del draw

# write to stdout
im.save(sys.stdout, "PNG")

基本概念
坐标系
和PIL使用同样的坐标系.(0,0)位于左上角
颜色

类型参数
“1”,”L”,”I”使用integers
“RGB”3个长度的元组,每个位上是 integers
“F”integers或者floating
“P”color indexes或者RGB 3-tuples或者clolor name

创建绘图对象

class PIL.ImageDraw.Draw(im, mode=None)
方法描述
getfont()获得默认的font
arc(xy, start, end, fill=None)做圆
bitmap(xy, bitmap, fill=None)画bitmap(mask)
chord(xy, start, end, fill=None, outline=None)类似arc(),起点和终点会连起来
ellipse(xy, fill=None, outline=None)椭圆
line(xy, fill=None, width=0)直线
pieslice(xy, start, end, fill=None, outline=None)类似arc()
point(xy, fill=None)画点
polygon(xy, fill=None, outline=None)多边形
rectangle(xy, fill=None, outline=None)长方形
text(xy, text, fill=None, font=None, anchor=None, spacing=0, align=”left”, direction=None, features=None)文字
multiline_text(xy, text, fill=None, font=None, anchor=None, spacing=0, align=”left”, direction=None, features=None)
textsize(text, font=None, spacing=4, direction=None, features=None)返回当前字符串的大小
multiline_textsize(text, font=None, spacing=4, direction=None, features=None)
floodfill(image, xy, value, border=None, thresh=0)填充选中区域

参考文献:
http://pillow.readthedocs.io/en/latest/reference/ImageDraw.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值