如何将PNG图像转换为SVG?


当前回答

我刚刚发现这个问题和答案,因为我正试图做同样的事情!我不想使用其他提到的工具。(不想把我的电子邮件给别人,也不想付钱)。我发现Inkscape (v0.91)可以做得很好。本教程简单易懂。

它很简单,选择你的位图在Inkskape和Shift+Alt+B。

其他回答

I'm assuming that you wish to write software to do this. To do it naively you would just find lines and set the vectors. To do it intelligently, you attempt to fit shapes onto the drawing (model fitting). Additionally, you should attempt to ascertain bitmaped regions (regions you can't model through shames or applying textures. I would not recommend going this route as that it will take quite a bit of time and require a bit of graphics and computer vision knowledge. However, the output will much and scale much better than your original output.

注意那些使用potrace和imagemagick的人,将透明的PNG图像转换为PPM似乎不是很好。下面是一个在convert上使用-flatten标志来处理这个问题的例子:

sudo apt-get install potrace imagemagick
convert -flatten input.png output.ppm
potrace -s output.ppm -o output.svg
rm output.ppm

Another interesting phenomenon is that you can use PPM (256*3 colors, ie. RGB), PGM (256 colors, ie. grayscale) or PBM (2 colors, ie. white or black only) as the input format. From my limited observations, it would appear that on images which are anti-aliased, PPM and PGM (which produce identical SVGs as far as I can see) shrink the colored area and PBM expands the colored area (albeit only a little). Presumably this is the difference between a pixel > (256 / 2) test and a pixel > 0 test. You can switch between the three by changing the file extension, ie. the following use PBM:

sudo apt-get install potrace imagemagick
convert -flatten input.png output.pbm
potrace -s output.pbm -o output.svg
rm output.pbm

你可能想看看potrace。

你也可以试试http://image.online-convert.com/convert-to-svg

我总是用它来满足我的需要。

如果你使用的是Linux系统,imagemagick是完美的。即

convert somefile.png somefile.svg

这适用于大量不同的格式。

用于其他媒体,如视频和音频使用(ffmpeg) 我知道你清楚地说明png到svg,然而;这仍然与媒体有关。

ffmpeg -i somefile.mp3 somefile.ogg

如果你想浏览大量的文件,这是一个小技巧;一个循环使用基本的shell技巧。

for f in *.jpg; do convert $f ${f%jpg}png; done

这将删除jpg并添加png,这告诉转换你想要的。