Imagemagick svg to png conversion screws up text position
Asked Answered
O

0

1

Trying to use Imagemagick's conversion tool to do basic SVG to PNG conversions, but the text positions are completely out of whack.

For example, here's a vertical list of words in SVG:

SVG:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="360" height="360" version="1.1" style="display:block;">
  <rect width="100%" height="100%" fill="#FFFF00"/>
  <text x="0" y="20"  font-size="12" text-anchor="start" fill="black" transform="">HELLO</text>
  <text x="0" y="40" font-size="12" text-anchor="start" fill="black" transform="">HELLO</text>
  <text x="0" y="60" font-size="12" text-anchor="start" fill="black" transform="">HELLO</text>
</svg>

Which looks like this:

enter image description here

Convert with Imagemagick:

convert test.svg test.png

Result: test.png

enter image description here

Orotund answered 21/11, 2018 at 17:17 Comment(2)
Make sure either Inkscape or librsvg is installed on your system. Then imagemagick will delegate the conversion to one of them and avoid its faulty internal implementation. Test what is used with identify -list delegate | grep -i svgLind
What is your version of ImageMagick? Current versions work fine with both the internal MSVG renderer and using ImageMagick with Inkscape installed on my system. The RSVG 2.42.2 delegate gave an empty yellow image. I was using IM 6.9.10.14 Q16 Mac OSX.Clayborn

© 2022 - 2024 — McMap. All rights reserved.