readimageblob: Fatal Error when converting SVG into PNG

前端 未结 2 1246
渐次进展
渐次进展 2021-01-11 22:58

I\'m trying to use Image-Magick with PHP to convert SVG text into a PNG image. This SVG is a chart generated with NVD3 and I\'d like to allow my users to download it as an i

相关标签:
2条回答
  • 2021-01-11 23:26

    And remember that

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    

    must be the first line in a variable that contains SVG text. Knowing that may save you some headaches.

    0 讨论(0)
  • 2021-01-11 23:51

    svg file text structure needs to be specified for readImageBlob to decode the file. Prepend <?xml version="1.0" encoding="UTF-8" standalone="no"?> to your variable having svg text.

    $svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg;
    

    And you are good to go.

    0 讨论(0)
提交回复
热议问题