Thursday 28 May 2020

Inkscape - SVG to PNG conversion

Inkscape is an Open Source vector graphics editing application.
The primary file type  is the Scalable Vector Graphics format. Modern browsers support the format.

However, there are still applications where bit map or raster graphic formats are required (Microsoft Azure Marketplace still wants specific resolution PNG files). Inkscape is a useful tool to convert the SVG format files to PNG.

Inkscape is in the process of rolling out version 1.0 which changes the command line parameters - so check your version.

Installation

Inkscape is available via the Raspbian repository.
After updating and upgrading the operating system, use:
sudo apt-get install inkscape

You can check the installed version.
inkscape -V
Inkscape 0.92.1 r15371

Command line usage

Inkscape has an extensive GUI, but it can also be used via command line. This is particularly useful if you want to convert an SVG file to a number of different sizes.

You can see the full list of options by using:
inkscape -?
Or a concise list with:
inkscape --usage
The command line options used:
-z No GUI
-w Width
-h Height
-e Export file name

Example
inkscape -z -w 1024 -h 1024 picture.svg -e picture.png
WARNING: unknown type: svg:foreignObject
WARNING: unknown type: i:pgf
Background RRGGBBAA: ffffff00
Area 0:0:85.039:85.039 exported to 1024 x 1024 pixels (1155.99 dpi)
Bitmap saved as: picture.png

References

https://inkscape.org/
https://en.wikipedia.org/wiki/Inkscape
https://en.wikipedia.org/wiki/Scalable_Vector_Graphics
https://inkscape.org/doc/inkscape-man.html