drawing a line on an image with PIL

后端 未结 1 1144
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 07:17

I want to draw a line and show it. assume I have a PIL image.

draw = ImageDraw.Draw(pilImage)
draw.line((100,200, 150,300), fill=128)

How can I

相关标签:
1条回答
  • 2021-02-02 07:23

    This should work:

    from PIL import Image, ImageDraw
    im = Image.new('RGBA', (400, 400), (0, 255, 0, 0)) 
    draw = ImageDraw.Draw(im) 
    draw.line((100,200, 150,300), fill=128)
    im.show()
    

    Basically using ImageDraw draw over the image, then display that image after changes, to draw a thick line pass width

    draw.line((100,200, 150, 300), fill=128, width=3)
    
    0 讨论(0)
提交回复
热议问题