Page 1 of 1

Convert SVG to PNG

Posted: 2014-07-30T10:34:32-07:00
by novito
I am trying to find a way to convert any SVG image to a PNG.

Here is what I have tried so far:

convert -background none logo_svg.svg b.png

In some cases, the PNG image is written (even though there are missing colors), even though the image is not the same one. Example:

Original Image: http://jet-computing.com/wp-content/upl ... x.svg_.png
Result: http://imgur.com/pywEaZs

And in other cases, such as this case:

Original: http://demandware.edgesuite.net/aaci_pr ... s/logo.svg

When trying to run that command, I get: 'convert: non-conforming drawing primitive definition `path' @ error/draw.c/DrawImage/3179.'

Any thoughts?
For the records, here are the SVG libs that are shown when doing convert -list format:

SVG SVG rw+ Scalable Vector Graphics (XML 2.9.1)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.9.1)

Re: Convert SVG to PNG

Posted: 2014-07-30T10:42:54-07:00
by fmw42
What version of IM and platform are you using. And more importantly what delegate is being used for SVG -- IM internal MSVG (XML), RSVG or Inkscape.

convert -list format

see what delegate is listed for SVG

For example on my system

SVG SVG rw+ Scalable Vector Graphics (RSVG 2.40.2)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (RSVG 2.40.2)

You should use Inkscape or RSVG with the most current versions.

If there is still an issue, then your svg file may be corrupt or have non-standard syntax.

Some bugs in this regard have been fixed in current versions of IM.

From the changelog (some of the recent changes):

2014-07-19 6.8.9-6 Dirk Lemstra <dirk@snakeware...>
Fixed fill-rule in SVG clip path (reference viewtopic.php?f=2&t=25882).


2014-06-07 6.8.9-3 Dirk Lemstra <dirk@snakeware...>
Fixed creation of SVG from 8bim clip path. (reference viewtopic.php?f=1&t=25594).


2013-12-30 6.8.8-2 Cristy <quetzlzacatenango@image...>
Generate a proper SVG clipping path (reference viewtopic.php?f=3&t=24752).


2012-12-21 6.8.8-0 Dirk Lemstra <dirk@snakeware...>
Made librsvg the default svg library for the windows distribution.

Re: Convert SVG to PNG

Posted: 2014-07-30T11:07:23-07:00
by snibgo

Code: Select all

convert -background none logo_svg.svg b.png
This works fine with IM 6.8.9-5 with Inkscape as the renderer.

Re: Convert SVG to PNG

Posted: 2014-07-30T11:59:00-07:00
by novito
Hi guys,

I am using Version: ImageMagick 6.8.8-3 Q16 x86_64 2014-03-03 http://www.imagemagick.org (for MAC)

And the

Code: Select all

convert -list format
shows me this (regarding SVG):

SVG SVG rw+ Scalable Vector Graphics (XML 2.9.1)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.9.1)

I don't see any RSVG there, so I guess your suggestions would be to install RSVG and reinstall ImageMagick?

Re: Convert SVG to PNG

Posted: 2014-07-30T12:08:07-07:00
by snibgo
MSVG is very limited. I guess it just can't cope with paths.

As you goal is to convert any SVG, I suggest Inkscape is the most suitable delegate.

Re: Convert SVG to PNG

Posted: 2014-07-30T12:15:01-07:00
by novito
How can I tell ImageMagick to use Inkscape as a delegate for SVG? I am on my way to reinstall ImageMagick with MacPorts: https://trac.macports.org/browser/trunk ... k/Portfile

Re: Convert SVG to PNG

Posted: 2014-07-30T12:19:54-07:00
by snibgo
On Windows, just install Inkscape and put its directory on the system path. I don't know about other platforms.

Re: Convert SVG to PNG

Posted: 2014-07-30T13:03:04-07:00
by novito
You guys rock. For the records, this is what I did:

Code: Select all

port uninstall imagemagick
brew install librsvg
port install imagemagic +rsvg
Voila, problem solved. Thanks guys.