You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
介绍:
a SVG 1.1 to PNG, PDF, PS and SVG converter;
a command-line interface;
a Python 3.4+ library;
known to work at least on Linux, OS X, and Windows;
based on the Cairo 2D graphics library;
tested using the W3C test suite;
LGPLv3-licensed free software.
cairoSVG
官网:http://cairosvg.org/
cairoSVG由于是根据svg代码生成,所以在美观上会比python pycha好看很多。
安装
pip install cairosvg
安装过程参考这里。
windowns下安装,反复提示
AttributeError: 'module' object has no attribute 'ANTIALIAS_FAST'
。多次尝试后,安装步骤如下:2、
pip install lxml
3、
pip install cairosvg
4、
pip install cairocffi
(如果这步有误,可尝试pip install cairocffi==0.6
指定版本)5、
pip install pycairo
(豆瓣貌似没有此源)如果以上5步后,还没有成功,需要进行第6步
6、最后一步,安装GTK2,这步。相关资料
下载地址:GTK2 / GTK3
重启pycharm后,就可以正常使用了
使用
cairoSVG 提供了4个函数:
官方的栗子:
我们实际的需求,是人工生成,所以直接将前台传递过来的svg代码转换为图片,具体代码如下:
参考文章:
Installing cairo on Windows
AttributeError: 'module' object has no attribute 'ANTIALIAS_FAST'
The text was updated successfully, but these errors were encountered: