python PIL画线 矩形 椭圆 画图

QQ群:476842922(欢迎加群讨论学习)
from PIL import Image, ImageDraw,ImageFont

Image1 = Image.open("nnn.jpg")

draw =ImageDraw.Draw(Image1)
draw.line((20, 20, 150, 150), 'cyan')
draw.rectangle((100, 200, 300, 400), 'black', 'red')
draw.arc((100, 200, 300, 400), 0, 180, 'yellow')
draw.ellipse((350, 300, 500, 400), 'yellowgreen', 'wheat')

font = ImageFont.truetype("consola.ttf", 40, encoding="unic")#设置字
draw.text((100, 50), u'Hello World', 'fuchsia', font)

#draw.line((0,0) +Image1.size, fill=128)
Image1.show()
Image1.save("www.jpeg", "JPEG")

python PIL画线 矩形 椭圆 画图_第1张图片

你可能感兴趣的:(代码,python)