For lines and ellipses in PIL, the images are rough.
I found antialiasing only in resize and thumbnail.
Is there any way to do antialiasing when drawing a line or ellipse?
As you can see, anti-aliasing has reduced the jaggedness and created a "smoother" look. This is achieved by blending the pixels on the edge of the text with the background. The jaggs are not completely opaque, but are partially transparent.
Antialiasing is a technique used in digital imaging to reduce the visual defects that occur when high-resolution images are presented in a lower resolution. Aliasing manifests itself as jagged or stair-stepped lines (otherwise known as jaggies) on edges and objects that should otherwise be smooth.
To resize an image, you call the resize() method on it, passing in a two-integer tuple argument representing the width and height of the resized image. The function doesn't modify the used image; it instead returns another Image with the new dimensions.
Anti-aliasing is the smoothing of jagged edges in digital images by averaging the colors of the pixels at a boundary. The letter on the left is aliased. The letter on the right has had anti-aliasing applied to make the edges appear smoother.
The only way to do it natively is with supersampling. Render your image at a multiple of the size you require, then resize
it with resample=Image.ANTIALIAS
, e.g.:
im = im.resize((width // 2, height // 2), resample=Image.ANTIALIAS)
aggdraw (http://effbot.org/zone/aggdraw-index.htm) may be something you're interested in.
The aggdraw module implements the basic WCK 2D Drawing Interface on top of the AGG library. This library provides high-quality drawing, with anti-aliasing and alpha compositing, while being fully compatible with the WCK renderer.
The aggdraw module can be used with PIL or the WCK library (under Tkinter or native Windows). It can also be used as a stand-alone library.
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