rsvg-convert svg to png


There are a few ways to convert an SVG to a PNG without leaving the shell, including *Magick and Inkscape, but I find rsvg-convert the easiest.

Install with Homebrew on macOS, or FreeBSD pkgng. Note the version number on the latter:

# brew install librsvg
# pkg install librsvg2

Then convert as such:

$ rsvg-convert vector.svg

And you’ll be presented with a PNG:

==> ?g?O2??a?{*pD????껌?Xh???4?mF:,?ɶ?0?c3??nb??ܡ?z?
==> ?5??&?4?KZڴ?;w??qt??6>2???hłr??FM???DZ??#_@??{'y
==> ???d??$???xB??birdistheword5??{|?9?ND?x{?????mPJ
==> ?????V?@?'?W\7?M~???h?(RD1???cx@?^E???wy?뢪???ˏ?
==> ;?*??z;KFåIP?L???b??2)??_?HgH?E??9\?̽?Wr?N???J???
==> ?p?4#7O??^e#Ւ?%,{O41?J??}1?$7H???,?I??S?T?/?[ӹ??
==> ??~IA70=????к\??|?<f_??kb?\j|?d?Ә??ʭ??dٌ?

Whoa! I wasn’t expecting that. Let’s redirect somewhere useful:

$ rsvg-convert vector.svg > raster.png

Or even better, use the output flag:

$ rsvg-convert --output raster.png vector.svg

More details are available with --help, or on the manpage(1).

Author bio and support


Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

You can leave me a comment by contacting me, and I might publish your thoughts. Please read the FAQs first though.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!