Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert SVG to png or other?

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')

If I do svg = SVG(filename='../images/python_logo.svg')

How can I save it to a png file ?

like image 766
DavidK Avatar asked May 18 '15 11:05

DavidK


People also ask

Should I export as PNG or SVG?

PNGs and SVGs support transparency — so they're both excellent choices for online logos and graphics. It's worth noting that PNGs are one of the best choices for a raster-based transparent file. If you're working with pixels and transparency, PNGs are a better option than SVGs.

Which has better quality JPEG or PNG or SVG?

If you're going to be using high quality images, detailed icons or need to preserve transparency, PNG is the winner. SVG is ideal for high quality images and can be scaled to ANY size.


1 Answers

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.

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).

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.

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

like image 169
jcoppens Avatar answered Sep 30 '22 11:09

jcoppens