将SVG转换为png或其他格式? [英] Convert SVG to png or other?

查看:293
本文介绍了将SVG转换为png或其他格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于在iPython笔记本中非常容易显示SVG文件的内容,是否还有一种方法(也很容易)来获取我们在png文件或其他文件中看到的内容?

Since it's very easy to display the content of a SVG file inside the iPython notebook, is there also a way (easy too) to get what we see inside a png file or other ?

from IPython.display import SVG
SVG(filename='../images/python_logo.svg')

如果我svg = SVG(filename='../images/python_logo.svg')

如何将其保存到png文件中?

How can I save it to a png file ?

推荐答案

SVG是矢量图像(将图形保存为绘制直线,圆等的命令). PNG是位图.因此,要将SVG转换为PNG,您需要一个渲染器.

SVG are vectors images (the drawings are saved as commands to draw lines, circles, etc). PNGs are bitmaps. So to convert SVG to PNG, you need a renderer.

最明显的解决方案是ImageMagick,这是您已经安装的库,因为它已在多个程序中使用.一种不太明显的方法是使用Inkscape.使用命令行选项,可以将Inkscape用作转换程序.由于Inkscape是面向矢量的,因此我怀疑质量要好于ImageMagick(后者更注重位图).

The most obvious solution is ImageMagick, a library you have already installed, as it is used in several programs. A less obvious approach is using Inkscape. Using the commandline options, it's possible to use Inkscape as a conversion program. As Inkscape is vector oriented, I suspect quality to be better than ImageMagick (which is more bitmap-minded).

由于矢量图像(SVG)是包含绘图指令的文本文件,因此更易于理解. PNG仅包含像素信息,而且,更糟的是,它们使用相当复杂的算法进行压缩.弄清楚它们并不容易.

As a vector image (SVG) is a text file containing drawing instructions, it's easier to understand. PNGs contain just pixel information, and, to make things worse, they are compressed with a fairly complicated algorithm. Making sense of them is not as easy.

看看 Inkscape手册页,它的使用方式非常明显. 这是IMagick转换帮助.

Have a look at the Inkscape man page, it's fairly obvious how to use it. This is the IMagick convert help.

这篇关于将SVG转换为png或其他格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆