Aug 11, 2015 - Here's a small tip: If you want to convert SVG to PNG on OSX there are several things you could try. One of those is a tiny 'secret' app build.
I have a SVG file which has a defined size of 16x16. When I use Image Magick's convert program to convert it into a PNG then I get a 16x16 pixel PNG which is way too small: convert test.svg test.png I need to specify the pixel size of the output PNG.size parameter seems to be ignored, -scale parameter scales the PNG after it has been converted to PNG. The best result up to now I got by using the -density parameter: convert -density 1200 test.svg test.png But I'm not satisfied because I want to specify the output size in pixels without doing math to calculate the density value. So I want to do something like this: convert -setTheOutputSizeOfThePng 1024x1024 test.svg test.png So what is the magic parameter I have to use here? If you are on MacOS X and having problems with Imagemagick's convert, you might try reinstalling it with RSVG lib. Using HomeBrew: brew remove imagemagick brew install imagemagick -with-librsvg Verify that it's delegating correctly: $ convert -version Version: ImageMagick 6.8.9-8 Q16 x-12-17 Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC Features: DPC Modules Delegates: bzlib cairo fontconfig freetype jng jpeg lcms ltdl lzma png rsvg tiff xml zlib It should display rsvg. Inkscape doesn't seem to work when svg units are not px (e.g.
I got a blank image. Maybe, it could be fixed by twiddling the dpi, but it was too troublesome. Svgexport is a node.js program and so not generally useful.
Imagemagick's convert works ok with: $ convert -background none -size 1024x1024 infile.svg outfile.png If you use -resize, the image is fuzzy and the file is much larger. BEST $ rsvg -w 1024 -h 1024 infile.svg outfile.png It is fastest, has the fewest dependencies, and the output is about 30% smaller than convert.
Install librsvg2-bin to get it. There does not appear to be a man page but you can type: $ rsvg -help to get some assistance. Simple is good. I've solved this issue through changing the width and height attributes of the tag to match my intended output size and then converting it using ImageMagick. Works like a charm.