Mik*_*ark 5 php svg jpeg imagick
我尝试了许多不同的解决方案,但不能使用Imagick :: readImageBlob,将不胜感激。
错误信息:
Caught exception: no decode delegate for this image format `' @ error/blob.c/BlobToImage/364
Run Code Online (Sandbox Code Playgroud)
码:
$svg = file_get_contents($this->svg);
$image = new Imagick();
$image->readImageBlob($svg);
//...
Run Code Online (Sandbox Code Playgroud)
SVG:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" width="928" height="933" id="parent">
<image width="928" height="933" xlink:href="image.jpg" ></image>
<path id="path1" fill="none" d="M100,656.5c-105.1-200.5-28.1-448,172-553s447.5-27.5,552.6,173s28.1,448-172,553 S205.1,856.9,100,656.5z"/>
<text text-anchor="middle">
<textPath xlink:href="#path1" startOffset="33.3333%">
<tspan>top</tspan>
</textPath>
</text>
<path id="path2" fill="none" d="M121.8,264.8C10.2,453.3,72.2,696.3,260.3,807.7s431,48.9,542.6-139.5 s49.5-431.5-138.5-542.8S233.3,76.4,121.8,264.8z"/>
<text text-anchor="middle">
<textPath xlink:href="#path2" startOffset="33.3333%">
<tspan>bund</tspan></textPath>
</text>
</svg>
Run Code Online (Sandbox Code Playgroud)
经过@Native Coder 和@karser 的回答尝试后,我的 SVG 仍然生成相同的无解码委托错误。在我添加<?xml version="1.0" encoding="UTF-8" standalone="no"?>为 SVG 内容的开头行后,它起作用了。值得检查您的 XML 也是有效的。
对我来说,这些 deps 丢失了(ubuntu 16.04):
sudo apt-get install libgraphicsmagick1-dev libmagickcore-dev libmagickcore-6.q16-2 libmagickcore-6.q16-2-extra
Run Code Online (Sandbox Code Playgroud)
预期输出:
identify -list format | grep SVG
MSVG SVG rw+ ImageMagick's own SVG internal renderer
SVG SVG rw+ Scalable Vector Graphics (RSVG 2.40.13)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (RSVG 2.40.13)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4007 次 |
| 最近记录: |