cairosvg 的命令行版本允许缩放。这是帮助函数的输出:
cairosvg -h
usage: cairosvg [-h] [-v] [-f {pdf,png,ps,svg}] [-d DPI] [-W WIDTH]
[-H HEIGHT] [-s SCALE] [-u] [-o OUTPUT]
input
CairoSVG - A simple SVG converter based on Cairo.
positional arguments:
input input filename or URL
optional arguments:
-h, --help show this help message and exit
-v, --version show program\'s version number and exit
-f {pdf,png,ps,svg}, --format {pdf,png,ps,svg}
output format
-d DPI, --dpi DPI ratio between 1 inch and 1 pixel
-W WIDTH, --width WIDTH
width of the parent container in pixels
-H HEIGHT, --height HEIGHT
height of the parent container in pixels
-s SCALE, --scale SCALE
output scaling factor
也可以看看cairosvg 文档
使用时如何指定比例因子cairosvg2png
Python 脚本内部?
我有同样的问题 - 文档没有明确说明这一点,但事实证明,它就像传递scale=2.0
的关键字参数svg2png
method.
import cairosvg
input_fn = '/home/me/input.svg'
output_fn = '/home/me/output.png'
cairosvg.svg2png(url=input_fn, write_to=output_fn, scale=2.0)
这在 2.0.3 版本上绝对适合我。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)