The Mijingo Blog

Latest news, updates, free tutorials, and more from Mijingo.

Exporting SVG from the Command Line with Inkscape

by Ryan Irelan

I’ll go ahead and say this up front: using Inkscape isn’t the most desirable method. Not because Inkscape is an unreliable tool but because it requires that the Inkscape app and X11 app are both installed. Inkscape is a cross-platform application so it runs on X-Windows and provides a non-native app experience.

But if you are already using Inkscape to draw your SVGs, then you would be best served scripting the command line tool of the tool that you already have open.

There are two ways to interact with Inkscape from the command line:

  1. Using the Inkscape interactive shell mode
  2. Running the inkscape command line tool

The interactive shell mode is enabled by running inkscape --shell.

If you want to do scripting (like bash scripting) to batch process images, the command line tool is your best option.

On OS X, the command line utility is located inside of the Inkscape application package, which you can find at: /Applications/ If you want to call this like I do below, you’ll want to add the location to your system path.

Using the same file we used in the tutorial on using svgexport, here’s how to convert an SVG to PNG with the Inkscape command line utility:

inkscape -z css3-fundamentals.svg -e css3-fundamentals.png

The first part calls the inkscape utility. The -z option is supposed to suppress the Inkscape GUI. This sort of worked for me, but still required X11 on OS X to launch.

The -e option tells Inkscape that we want to covert to a PNG image. And, then we pass in the name and extension of the destination image.

This SVG to PNG conversion method is very reliable if you already have Inkscape installed. If you don’t run Inkscape already then you might want to check out my tutorial on exporting SVG with SVGExport.

Learn more about SVG with our comprehensive course: Up and Running with SVG

Filed Under: Free Tutorials, SVG