The answer is on the answer I flagged, but is in the comments. Basically, see here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=18816
Run this on Mac with Ports:
sudo port install ImageMagick +rsvg
Here's my original Question:
My test.svg file is here: https://gist.github.com/2727243
Imagemagick version: ImageMagick 6.7.6-9 2012-05-18 Q16 (just updated today)
I have a SVG file the does a defs -> symbol to define an arrow symbol. Later on in the document I xlink:use that symbol. This works fine in Chrome and the arrow comes up and is in its proper position:
However, if I convert the image via imagemagick like so:
convert test.svg test.png
It doesn't work. Here's what I get:
The "use" appears to be ignored completely, and instead the arrow is rendering at the def. At least, near as I can tell.
Am I formatting my SVG wrong for Imagemagick to handle this scenario? Or is this just something that Imagemagick doesn't support properly? I've been looking all over for a definitive answer and can't find one, one way or the other.
I also tried the SVG here: http://www.carto.net/svg/samples/symbol.svg and the symbols did NOT work. So I'm leaning toward Imagemagick being the culprit.
UPDATE: I tried changing the def to the following:
<symbol id="arrow" x="25">
In the browser, the arrow DOES move 25 to the right, but in Imagemagick it sticks to (0,0). This was leading me to believe that it's less about the symbol definition and more about it not translating it properly. However, even if I try a straight transform on the "use" and, even better, remove the "use" entirely, the arrow still appears.
Update: This seams to be a bug in the default SVG renderar in ImageMagick that ignores
x
andy
onuse
tags (and also ignores transform attributes ong
tags). Try to use the rsvg backend instead.Does it work if you change:
To:
Can you give more detail as to why you have to use IM? If it turns out that IM is useless in this case, surely you would have to use something else? I second Inkscape for this.
That said, perhaps you can still use IM if you're willing to do some XML manipulation. I presume the contents of a symbol could be copied to their
<use>
locations individually; it's a messy workaround if you have lots of uses of the same symbol, but if you want to stick with IM it may be your only way forward. I'm working on the theory that it's the symbol system that is confusing IM - if the path is 'inline' it might be ok.