I'm dawing a simple pieslice with PIL
image = Image.new("RGBA", (256, 128), "#DDD")
draw = ImageDraw.Draw(image, image.mode)
draw.pieslice((0, 0 , 64, 64), 180, 270, fill="white)
del draw
image.save("file.png", "PNG")
As you can see the arc is not perfect. How I can make a perfect arc with PIL?
Draw on a larger image, then downscale:
N=4
image = Image.new("RGBA", (256*N, 128*N), "#DDD")
draw = ImageDraw.Draw(image, image.mode)
draw.pieslice((0, 0 , 64*N, 64*N), 180, 270, fill="white")
del draw
image = image.resize((256,128)) # using user3479125's correction
image.save("file2.png", "PNG")
Note for unutbu's answer: Now the resize() returns a resized copy of an image. So it doesn't modify the original. So this should be:
N=4
image = Image.new("RGBA", (256*N, 128*N), "#DDD")
draw = ImageDraw.Draw(image, image.mode)
draw.pieslice((0, 0 , 64*N, 64*N), 180, 270, fill="white")
del draw
image = image.resize((256,128))
image.save("file2.png", "PNG")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With