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

Max*_*mit 5 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>
Run Code Online (Sandbox Code Playgroud)

当我运行以下 ImageMagick 脚本时

 convert 26.svg 26.png
Run Code Online (Sandbox Code Playgroud)

我得到的只是一个空的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>
Run Code Online (Sandbox Code Playgroud)

ImageMagick 正确转换它,但这里的问题是我的文本在一行上,我需要它在多行上并受宽度限制

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

一个好的解决方法是将文本换行到第二个 SVG 中。但我不太确定如何做到这一点,并根据宽度让文本跳线。

有任何想法吗 ?