ImageMagick将带有文本的svg转换为png会产生空白图像

时间:2014-02-19 17:24:33

标签: svg imagemagick

这是我的svg

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svgfile" style="position:absolute; height:1200px; width:1600px;" version="1.1" viewBox="0 0 1600 1200">
<g class='shape' id='draw136.1' shape='text1' style='word-wrap: break-word; font-family: Arial; font-size: 30.599999999999998px;' undo='-1'>
  <switch>
    <foreignObject color='#000000' height='67.53719008264463' width='216.80495662949198' x='740.5638166047088' y='501.5702479338843'>
      <p xmlns='http://www.w3.org/1999/xhtml'>Test Writing in the box</p>
    </foreignObject>
  </switch>
</g>
</svg>

当我运行以下ImageMagick脚本时

 convert 26.svg 26.png

我得到的只是一个空的png

所以,如果我将我的svg改为以下形式

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svgfile" style="position:absolute; height:1200px; width:1600px;" version="1.1" viewBox="0 0 1600 1200">
    <text color='#000000' style='font-family: Arial; font-size: 30.599999999999998px;' height='67.53719008264463' width='216.80495662949198' x='740.5638166047088' y='501.5702479338843'>
    Test Writing in the box
    </text>
</svg>

ImageMagick正确转换它,但问题是我的文字在一行上,我需要它在多行上并以宽度为界

我的SVG可能有问题吗?或者这是一个ImageMagick问题吗?

一个很好的解决方法是将文本包装在第二个SVG中。但我不太清楚如何做到这一点,并根据宽度有文本跳线。

有什么想法吗?

0 个答案:

没有答案
相关问题