首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Imagick SVG to JPG -渲染结果中缺少JPG

Imagick SVG to JPG -渲染结果中缺少JPG
EN

Stack Overflow用户
提问于 2016-02-27 21:39:23
回答 1查看 107关注 0票数 0

我在使用嵌入式JPG转换svg2jpg时遇到了一些问题。下面的代码在另一台服务器上运行得很好。嵌入式PNG运行良好,只有JPG才会带来麻烦。`

代码语言:javascript
复制
    // 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服务器上运行良好)

有什么想法吗?

亲切的问候

EN

回答 1

Stack Overflow用户

发布于 2016-02-28 00:13:23

这个问题是由data:image type "data:image/jpg“不起作用引起的。必须指定为"data:image/jpeg“。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35670484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档