Python PIL有反锯齿方法吗?

时间:2023-02-07 23:41:21

For lines and ellipses in PIL, the images are rough.

对于PIL中的线和椭圆,图像都是粗糙的。

I found antialiasing only in resize and thumbnail.

我只在缩放和缩略图中找到了抗锯齿。

Is there any way to do antialiasing when drawing a line or ellipse?

在绘制直线或椭圆时是否有方法进行反走样?

2 个解决方案

#1


14  

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 filter=Image.ANTIALIAS.

唯一的方法是使用超整数。将图像呈现为所需大小的倍数,然后使用filter= image . antialias来调整它的大小。

#2


2  

aggdraw (http://effbot.org/zone/aggdraw-index.htm) may be something you're interested in.

aggdraw (http://effbot.org/zone/aggdraw-index.htm)可能是您感兴趣的内容。

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.

aggdraw模块在AGG库上实现了基本的WCK 2D绘图界面。该库提供高质量的绘图,具有抗锯齿和阿尔法合成,同时与WCK渲染器完全兼容。

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.

aggdraw模块可用于PIL或WCK库(在Tkinter或本机窗口下)。它还可以用作独立的库。

#1


14  

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 filter=Image.ANTIALIAS.

唯一的方法是使用超整数。将图像呈现为所需大小的倍数,然后使用filter= image . antialias来调整它的大小。

#2


2  

aggdraw (http://effbot.org/zone/aggdraw-index.htm) may be something you're interested in.

aggdraw (http://effbot.org/zone/aggdraw-index.htm)可能是您感兴趣的内容。

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.

aggdraw模块在AGG库上实现了基本的WCK 2D绘图界面。该库提供高质量的绘图,具有抗锯齿和阿尔法合成,同时与WCK渲染器完全兼容。

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.

aggdraw模块可用于PIL或WCK库(在Tkinter或本机窗口下)。它还可以用作独立的库。