如何用Image Magick将SVG转换为PNG? [英] How to convert a SVG to a PNG with Image Magick?
问题描述
我有一个SVG文件,其定义大小为16x16。当我使用Image Magick的转换程序将其转换为PNG时,我得到一个16x16像素的PNG太小了:
I have a SVG file which has a defined size of 16x16. When I use Image Magick's convert program to convert it into a PNG then I get a 16x16 pixel PNG which is way too small:
convert test.svg test.png
我需要指定输出PNG的像素大小。 -size
参数似乎被忽略, -scale
参数缩放PNG 后已转换为PNG。到目前为止我使用 -density
参数获得的最佳结果:
I need to specify the pixel size of the output PNG. -size
parameter seems to be ignored, -scale
parameter scales the PNG after it has been converted to PNG. The best result up to now I got by using the -density
parameter:
convert -density 1200 test.svg test.png
但我不满意,因为我想要指定输出大小(以像素为单位)而不进行数学计算以计算密度值。所以我想做这样的事情:
But I'm not satisfied because I want to specify the output size in pixels without doing math to calculate the density value. So I want to do something like this:
convert -setTheOutputSizeOfThePng 1024x1024 test.svg test.png
那么我在这里使用的神奇参数是什么?
So what is the magic parameter I have to use here?
推荐答案
在这个例子中,我无法从ImageMagick中获得好的结果,但是Inkscape在它上面做得很好Linux和Windows:
I haven't been able to get good results from ImageMagick in this instance, but Inkscape does a nice job of it on Linux and Windows:
inkscape -z -e test.png -w 1024 -h 1024 test.svg
以下是使用此命令将16x16 SVG缩放为200x200 PNG的结果:
Here's the result of scaling a 16x16 SVG to a 200x200 PNG using this command:
仅供参考,我的Inkscape版本(在Ubuntu 12.04上)是:
Just for reference, my Inkscape version (on Ubuntu 12.04) is:
Inkscape 0.48.3.1 r9886 (Mar 29 2012)
在Windows 7上,它是:
and on Windows 7, it is:
Inkscape 0.48.4 r9939 (Dec 17 2012)
这篇关于如何用Image Magick将SVG转换为PNG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!