Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using this command to generate a sharp 512px wide version of an SVG file that I have:

convert -geometry 256 pinterest.svg pinterest.png

This is the source file:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "">
<svg version="1.1" id="Layer_1" xmlns="" xmlns:xlink="" x="0px" y="0px"
         width="16px" height="16px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<path fill="#231F20" d="M8,0C3.582,0,0,3.582,0,8c0,3.275,1.97,6.09,4.789,7.327c-0.022-0.559-0.005-1.229,0.139-1.837

However it produces a blurry PNG:


As my source is a vector illustration, I was expecting to get a sharp image. Is there a way to do so?

share|improve this question
The problem is the width="16px" height="16px" in the SVG file. Try changing the ImageMagick command to convert -resize 3200% pinterest.svg pinterest.png for a 512x512 image. Not sure if you'll need a -geometry 512 too or not. – martineau May 23 '13 at 2:41
That didn't work either. I tried it with and without -geometry. It produces a blurry image. Even -density doesn't work. However I managed to achieve my desired results using Apache Batik. – 0xcafebabe May 23 '13 at 5:55
A slightly different approach might be something like what is described in this answer. – martineau May 23 '13 at 7:02

I had the same problem, but I sort of went around it by setting the density first.

for %f in (*.svg) do (convert -antialias -background transparent -density 600 -resize 1024x1024 %f %~nf.png)

share|improve this answer

I didn't find a way to solve this issue using ImageMagick, but Apache Batik's rasterize script can be used to convert and resize the SVG to PNG in a lossless fashion.

java -jar batik-rasterizer.jar samples/batikFX.svg

See here for more information.

share|improve this answer
Just a nitpick, but it really doesn't make sense to call a conversion from vector to raster graphics "lossless" -- an image file is a completely different representation and will always be an approximation of the graphics defined in vector format. – martineau May 23 '13 at 7:05
convert -density 2304 pinterest.svg pinterest.png

Because the original DPI is 72 and the pixel size is 16x16, so 512/16*72 is 2304.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .