我在使用嵌入式JPG转换svg2jpg时遇到了一些问题。下面的代码在另一台服务器上运行得很好。嵌入式PNG运行良好,只有JPG才会带来麻烦。`
// iterating all image children
foreach ($xml->xpath('//image') as $image) {
// fetching the xlink:href attribute
$xlinkHref = $image->attributes('xlink', TRUE)->href;
if ($xlinkHref != "") {
$type = pathinfo($xlinkHref, PATHINFO_EXTENSION);
$data = file_get_contents($xlinkHref);
$xlinkHref = 'data:image/' . $type . ';base64,' . base64_encode($data);
// now setting the new attribute value
$image->attributes('xlink', TRUE)->href = $xlinkHref;
}
}ImageMagick版本: 6.7.8-9 2014-06-10 Q16 (该代码在版本为6.7.2-7 2013-03-18 Q16的旧版ImageMagick服务器上运行良好)
有什么想法吗?
亲切的问候
发布于 2016-02-28 00:13:23
这个问题是由data:image type "data:image/jpg“不起作用引起的。必须指定为"data:image/jpeg“。
https://stackoverflow.com/questions/35670484
复制相似问题