Qais "qaisjp" Patankar

Converting an `svg` to a `png`

07 Apr 2017

I needed to convert a logo in svg form to a huge transparent png for a custom t-shirt. I used ImageMagick to do this.

On macOS

Make sure you install ImageMagick like this through brew:

brew install imagemagick --with-librsvg

Confirm this by doing convert --version and looking for rsvg in the delegates list, as shown below:

➜ convert --version
Version: ImageMagick 7.0.5-4 Q16 x86_64 2017-04-07 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib cairo fontconfig freetype jng jpeg ltdl lzma png rsvg tiff xml zli

The command

convert -background none -density 300 -resize 3543x3543 logo.svg logo.png
  • The density above is 300 DPI.
  • resize is the target size (3543x3543px)
  • -background none makes sure that the background is transparent