ImageMagick在转换为png时不应用svg过滤器 [英] ImageMagick not applying svg filters while converting to png

查看:141
本文介绍了ImageMagick在转换为png时不应用svg过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助识别问题。考虑这个SVG标记。

Can someone help identify the problem here. Consider this SVG markup.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="446.5 158 967 368">
    <defs>
        <filter color-interpolation-filters="sRGB" id="Sil2df3ui1g5" filterUnits="userSpaceOnUse">
            <feGaussianBlur stdDeviation="2" in="SourceAlpha"/>
            <feOffset result="offsetblur" dy="10" dx="10"/>
            <feFlood flood-color="orange"/>
            <feComposite operator="in" in2="offsetblur"/>
            <feComponentTransfer>
                <feFuncA slope="1" type="linear"/>
            </feComponentTransfer>
            <feMerge>
                <feMergeNode/>
                <feMergeNode in="SourceGraphic"/>
            </feMerge>
        </filter>
    </defs>
    <g>
        <g>
            <text stroke="#8f02d0" id="fsjd" fill="#00a7f2" transform="matrix(2.39,0,0,2.39,-1280.19,-438.545)" style="font-size: 60px; text-anchor: middle; stroke-linejoin: round; filter:url('#Sil2df3ui1g5'); font-weight: 400; font-style: normal; letter-spacing: 0px; stroke-width: 2;" y="333" x="921">Lorem</text>
            <text transform="matrix(1,0,0,1,-398,-145)" fill="#dd0000" style="font-size: 32px; text-anchor: middle; font-family: Ubuntu; font-style: normal; font-weight: 400; letter-spacing: 0px;" y="333" x="921">Safe Mode</text>
            <text transform="matrix(1,0,0,1,416,185)" fill="#179c00" style="font-size: 32px; text-anchor: middle; font-family: Ubuntu; font-style: normal; font-weight: 400; letter-spacing: 0px;" y="333" x="921">Safe Mode</text>
        </g>
    </g>
</svg>

当我尝试通过ImageMagick将此svg转换为png时:

When I try to convert this svg to png via ImageMagick :

convert -background none item.svg item.png

未应用过滤器

但是,如果我使用任何其他svg(由Inkscape / AI等生成..)它会成功转换。我想SVG标记有问题。

However, If I use any other svg(generated by Inkscape/AI etc..) It converts successfully. I guess something is wrong with SVG markup.

推荐答案

在为过滤器指定IRI的地方,不要使用单引号。

Where you specify the IRI for your filter, do not use single quotes.

更改此

filter:url('#Sil2df3ui1g5');

filter:url(#Sil2df3ui1g5);

至少在我的机器上,这可以解决问题。

At least on my machine, this fixes the problem.

根据W3C验证器,单引号应该没问题,好像是ImageMagick中的一个错误。

According to the W3C validator, single quotes should be OK, seems like a bug in ImageMagick.

这篇关于ImageMagick在转换为png时不应用svg过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆