free linux command line tool to convert SVG to PDF and/or some commonly-used bitmap format?

Imagemagick is great when rasterized (pixelated) output is what you want (or is at least acceptable), but is a bad choice otherwise, since it effectively embeds in the pdf a rasterized version of whatever you are trying to convert. The whole point of svg/pdf is that it can be vectorized, thereby smaller in size, while remaining smooth at any resolution.

So, I would definitely recommend using either Inkscape or CarioSVG. The latter has several command line utilities precisely for this purpose (svg2pdf, svg2ps and svg2png). The only hitch is that it is basically just a python egg, so if you don't have a python environment set up and aren't savvy enough (or don't care enough) to set one up, then that option is a no go. I tried myself, but had problems setting up the required libcairo (not that I tried too hard).

Inkscape is awesome, but the cli is a little clunky if you want just a quick little command to do all the work for you. I put together a couple of little scripts for taking care of this all for me:

svg2pdf

#!/bin/bash

for i in $@; do
  inkscape --without-gui --export-pdf="$(basename $i .svg).pdf" $i
done

svg2png

#!/bin/bash

for i in $@; do
  inkscape --without-gui --export-png="$(basename $i .svg).png" $i
done

Put the first one in ~/bin/svg2pdf and the latter in ~/bin/svg2png, run chmod +x on both of them to make them executable, and boom! You have a quick and easy shortcut for these often wanted operations that doesn't require you to think or remember how Inkscape's CLI works. (Obviously you need Inkscape installed before this will work)


There's Image Magick, and Inkscape also has command line tools.


Inkscape

To PDF:

inkscape -A a.pdf a.svg

to PNG:

inkscape -e a.png a.svg

Found at man inkscape and How to use Inkscape in commandline mode

Tags:

Linux

Svg