如何在PIL ImageDraw中增加多边形的厚度

时间:2015-10-17 14:26:58

标签: python python-imaging-library

我在使用PIL工作时,我在图像上绘制了bezier曲线,我想增加该曲线的厚度。这是我的代码:

for image in images:
    img = Image.open("/home/ec2-user/virtualenvs/axonator-production/axonator/media/app_data/ax_picture_20150831_213704.png").convert('RGBA')
    for annotation in image["annotations"]:
        xys = []
        frame = annotation["frame"].split(",")
        frame = [int(float(frame[0])),int(float(frame[1])),int(float(frame[2])),int(float(frame[3]))]
        frame_location = (frame[0],frame[1])
        frame_size = (5000 , 5000)
        for point in annotation["path"]:
            pt = point["points"].split(",")
            xys.append((pt[0],pt[1]))
        bezier = make_bezier(xys)
        points = bezier(ts)
        curve = Image.new('RGBA', frame_size)
        import pdb; pdb.set_trace()
        curve_draw = ImageDraw.Draw(curve)
        curve_draw.polygon(points,outline="red")
        curve_draw.text(points[0],str(order))
        order = order + 1
        img.paste(curve,frame_location,mask = curve)
    img.save('out.png')

1 个答案:

答案 0 :(得分:8)

功能lng无法采用宽度'像draw.polygon()这样的论点可以。

除此之外,line()将采用一系列点并绘制折线。

线条结尾将是丑陋的,但通过在结尾处绘制圆圈,你可以使它们漂亮!

下面的代码绘制了一个漂亮的厚红色多边形。

enter image description here

line()