Bug for ImageMagick to import SVG image

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
dengshenyu
Posts: 6
Joined: 2013-06-02T03:56:44-07:00
Authentication code: 6789

Bug for ImageMagick to import SVG image

Post by dengshenyu »

Hi IM devel members,
I have trouble when using ImageMagick to deal with SVG image. Here's the SVG image,

Code: Select all

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"  version="1.1"  viewBox="0 0 100 100">
  <defs>
    <linearGradient id="grad1">
      <stop offset="0%" stop-color="white"/>
      <stop offset="100%" stop-color="black"/>
    </linearGradient>
  </defs>
  <rect x="10" y="10" width="80" height="80" fill="url(#grad1)" stroke="blue"/>
</svg>
When I use 'identify' to get this image info, I was told "Geometry: 1x1+0+0". Why would this happen? Should I specify the 'width' and 'height' for svg tag?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bug for ImageMagick to import SVG image

Post by snibgo »

After copying your example into grad.svg, for IM 6.8.5-8 on Windows 7, I get the expected 100x100:

Code: Select all

D:\web\im>%IM%identify grad.svg
grad.svg SVG 100x100 100x100+0+0 16-bit sRGB 478B 0.031u 0:00.021

D:\web\im>%IM%convert grad.svg g.png

D:\web\im>%IM%identify g.png
g.png PNG 100x100 100x100+0+0 16-bit sRGB 597B 0.000u 0:00.000
snibgo's IM pages: im.snibgo.com
dengshenyu
Posts: 6
Joined: 2013-06-02T03:56:44-07:00
Authentication code: 6789

Re: Bug for ImageMagick to import SVG image

Post by dengshenyu »

snibgo wrote:After copying your example into grad.svg, for IM 6.8.5-8 on Windows 7, I get the expected 100x100:

Code: Select all

D:\web\im>%IM%identify grad.svg
grad.svg SVG 100x100 100x100+0+0 16-bit sRGB 478B 0.031u 0:00.021

D:\web\im>%IM%convert grad.svg g.png

D:\web\im>%IM%identify g.png
g.png PNG 100x100 100x100+0+0 16-bit sRGB 597B 0.000u 0:00.000
My IM is 6.5.4, and want to know why would this happen. Is it the librsvg library not working or something else?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bug for ImageMagick to import SVG image

Post by snibgo »

The oldest IM I have is 6.5.8-8, which gives me the same results as 6.8.5-8. But it might use a different delegate to your setup. I'm not an expert at IM configuration with libraries etc etc.

Inkscape is generally more comprehensive than IM at reading SVG files.
snibgo's IM pages: im.snibgo.com
dengshenyu
Posts: 6
Joined: 2013-06-02T03:56:44-07:00
Authentication code: 6789

Re: Bug for ImageMagick to import SVG image

Post by dengshenyu »

snibgo wrote:The oldest IM I have is 6.5.8-8, which gives me the same results as 6.8.5-8. But it might use a different delegate to your setup. I'm not an expert at IM configuration with libraries etc etc.

Inkscape is generally more comprehensive than IM at reading SVG files.
Thanks for infomation, but I need to figure out why would this happen. :-)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bug for ImageMagick to import SVG image

Post by fmw42 »

IM can use its internal MSVG or the external delegate for RSVG or I believe Inkscape. But I do not know how one would install or get an Inkscape delegate or program.


If you run

convert -format

and look at the line for SVG it should tell which it is using.

From http://www.imagemagick.org/script/formats.php

SVG RW Scalable Vector Graphics ImageMagick utilizes inkscape if its in your execution path otherwise RSVG. If neither are available, ImageMagick reverts to its internal SVG renderer. The default resolution is 90dpi.

There is a link to Inkscape in the comment on the page.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bug for ImageMagick to import SVG image

Post by snibgo »

fmw42 wrote:ImageMagick utilizes inkscape if its in your execution path...
Ah, I didn't know that. Just tested it, and it works! Thanks.

On installing Inkscape: for Windows, I just download and install from http://inkscape.org/download/?lang=en
snibgo's IM pages: im.snibgo.com
Post Reply