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)
Convert SVG to PNG
Convert SVG to PNG
Last edited by novito on 2014-07-30T10:51:08-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert SVG to PNG
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.
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert SVG to PNG
Code: Select all
convert -background none logo_svg.svg b.png
snibgo's IM pages: im.snibgo.com
Re: Convert SVG to PNG
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 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?
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
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?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert SVG to PNG
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.
As you goal is to convert any SVG, I suggest Inkscape is the most suitable delegate.
snibgo's IM pages: im.snibgo.com
Re: Convert SVG to PNG
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert SVG to PNG
On Windows, just install Inkscape and put its directory on the system path. I don't know about other platforms.
snibgo's IM pages: im.snibgo.com
Re: Convert SVG to PNG
You guys rock. For the records, this is what I did:
Voila, problem solved. Thanks guys.
Code: Select all
port uninstall imagemagick
brew install librsvg
port install imagemagic +rsvg