Closed ahmed4end closed 1 year ago
For the record, this was also discussed in #4765.
There isn't currently a direct way to do that. You could draw a larger image and then resize it using antialiasing.
from PIL import Image, ImageDraw
im = Image.new("RGBA", (200, 100), (0, 0, 0, 0))
draw = ImageDraw.Draw(im, "RGBA")
draw.rounded_rectangle((20, 20, 180, 80), 30, outline="#000")
im.save("normal.png")
for factor in range(2, 5):
im = Image.new("RGBA", (factor*200, factor*100), (0, 0, 0, 0))
draw = ImageDraw.Draw(im, "RGBA")
draw.rounded_rectangle((factor*20, factor*20, factor*180, factor*80), factor*30, outline="#000", width=factor)
im = im.resize((200, 100), Image.ANTIALIAS)
im.save(str(factor)+".png")
@radarhere this solution works for now, Is there any plans to implement anti-aliasing in general for the rounded rect and also the line func ?
No active plans, no.
@radarhere I have a question I would really love to answer That I am trying to use code:
draw = ImageDraw.Draw (im)
draw.rounded_rectangle ((20, 20, 180, 80), outline = "# 000")
I have this error: AttributeError: 'ImageDraw' object has no attribute 'rounded_rectangle' thank you very much In the end what I want to do is something like this:
What version of Pillow are you using?
from PIL import Image
print(Image.__version__)
rounded_rectangle()
was only added in 8.2.0.
@ahmed4end is there something new that you were after?
@radarhere performance of generating a rounded rectangle that's bigger by number of times then resizing is not great on some projects
on some projects
So it is ok on some projects? What is the difference between those?
the rounded edges is very sharp for a squircle! is there a way to use anti aliasing in the edges?