Python, Draw a circle with PIL

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I am looking for a command that will draw a circle on an existing image with PIL.

im = Image.open(path) 

I want a function that will draw a colored circle with radius r and center (x,y)

回答1:

image = Image.open("x.png") draw = ImageDraw.Draw(image) draw.ellipse((x-r, y-r, x+r, y+r), fill=(255,0,0,255)) 


回答2:

Use ImageDraw.ellipse with square bbox like (0,0,10,10), which mean with diameter 10.



回答3:

    image = Image.open("x.png")     draw = ImageDraw.Draw(image)     draw.ellipse((x-r, y-r, x+r, y+r), fill=(255,0,0,0)) 

using this way i am unable to make it translucent, it is always opaque



回答4:

image = Image.open("x.png") draw = ImageDraw.Draw(image) draw.ellipse((x-r, y-r, x+r, y+r), fill=(255,0,0,0)) 

using this way i am unable to make it translucent, it is always opaque

This problem can be solved by the solution given here: How do you draw transparent polygons with Python?

Direct link: https://stackoverflow.com/a/21768191

Best regards, Sven



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!