ImageMagick SVG转换为PNG - 路径边缘显示为灰色

时间:2015-08-24 19:50:45

标签: svg imagemagick png

我使用ImageMagick(v.5.5.7)从SVG创建PNG。我注意到路径边缘显示为灰色,即使路径是用纯色创建的。我认为这是由于抗锯齿所以我关闭了它:

convert +antialias box.svg  box__noantialias.png

但我得到完全相同的结果。结果如下:

grainy edge box

有没有人对如何解决这个问题有任何想法?不幸的是,我只能使用ImageMagick,所以我没有其他选择。

如果有人好奇,这是SVG:

<svg height="150" version="1.1" width="730" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;">
<desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Rapha�l 2.1.0</desc>
<defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></defs>
<path fill="none" stroke="#ffff00" d="M146,46L148,46L149,46L151,47L152,47L154,47L155,47L156,47L156,47L157,47L158,47L158,47L159,47L160,47L161,47L162,46L162,46L163,46L164,46L164,46L165,46L166,46L167,46L168,46L168,46L169,46L170,46L171,46L172,46L172,46L173,46L174,46L174,45L175,45L176,45L178,45L178,45L179,45L180,45L181,45L182,45L184,45L186,45L187,45L189,45L192,45L193,45L194,45L196,45L198,45L200,46L202,46L203,46L205,46L208,46L210,46L210,46L211,46L212,46L214,46L214,46L215,46L216,46L218,46L220,46L221,46L222,46L224,46L226,46L228,46L229,47L231,47L234,47L236,47L236,47L238,48L243,49L244,49L246,49L246,49L248,49L248,49L249,49L249,50L249,53L249,55L250,59L250,61L250,64L250,68L250,71L250,75L250,77L250,81L250,85L250,86L250,91L250,91L250,97L250,99L250,101L250,104L251,105L251,106L251,109L251,109L252,111L252,112L252,113L252,114L253,117L253,118L253,119L254,121L254,123L254,125L254,127L254,127L254,128L254,129L254,130L255,131L255,131L254,131L254,131L248,131L242,131L236,131L230,131L224,131L222,131L219,131L214,131L210,131L205,131L202,131L198,131L198,131L196,131L194,131L192,131L187,132L184,132L181,133L178,133L176,133L172,133L169,133L164,133L161,133L158,133L156,133L153,133L150,133L148,133L145,133L144,133L143,133L142,133L142,133L142,133L142,130L142,127L141,122L141,118L140,109L139,105L138,101L138,99L137,97L136,93L136,91L136,87L136,85L136,83L136,81L136,80L136,77L136,75L136,74L136,72L136,71L137,69L137,68L137,67L137,66L137,65L137,63L137,62L137,61L137,61L138,59L138,57L138,57L138,55L138,54L138,53L139,53L140,51L140,50L140,49L140,49L140,49L140,48L140,47" stroke-opacity="1" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" transform="matrix(1,0,0,1,0,0)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); stroke-opacity: 1; stroke-linecap: round; stroke-linejoin: round;"></path>
<path fill="none" stroke="#ffff00" d="M142,49L142,50L142,50L145,53L146,54L148,55L149,56L150,57L152,57L153,58L154,59L154,59L155,59L156,60L156,60L157,61L158,61L158,61L159,63L160,64L162,65L163,65L164,65L165,67L166,68L166,68L166,69L168,69L169,71L170,72L172,73L172,74L174,75L176,77L177,78L179,79L180,81L181,82L182,83L184,84L185,85L186,86L186,87L188,87L188,88L190,89L190,90L192,90L194,91L194,92L196,93L196,94L198,95L199,96L201,97L202,98L203,99L204,99L205,100L206,101L206,102L208,102L209,103L210,104L210,105L212,105L213,107L214,107L214,108L216,109L216,109L218,110L218,111L219,111L220,112L222,113L222,113L223,114L224,115L225,116L226,117L227,117L228,117L230,119L230,119L232,120L234,121L235,122L236,123L237,123L238,123L238,123L239,124L240,124L240,124L240,125L241,125L242,125L242,125L242,125L243,125L244,126L244,126L244,127" stroke-opacity="1" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" transform="matrix(1,0,0,1,0,0)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); stroke-opacity: 1; stroke-linecap: round; stroke-linejoin: round;"></path>
<path fill="none" stroke="#ffff00" d="M242,49L242,49L241,49L240,50L240,51L240,51L238,52L238,52L238,53L236,54L236,54L235,55L234,56L232,57L232,58L230,59L229,59L228,60L226,62L224,63L223,64L222,65L220,67L218,69L216,70L216,71L214,72L213,73L211,75L210,77L208,79L207,79L205,81L204,83L202,83L202,85L200,86L198,87L197,88L195,89L194,90L192,91L190,93L188,93L187,95L186,95L184,96L182,98L182,99L180,99L180,100L179,100L178,101L176,101L176,102L176,103L174,103L174,104L173,105L172,106L171,106L170,107L168,109L168,109L167,109L166,110L166,111L165,111L164,111L164,113L162,114L162,115L161,115L160,115L160,116L159,117L159,118L158,118L157,119L156,119L156,120L155,121L154,121L154,122L154,123L152,123L152,123L152,124L150,124L150,125L149,125L148,126L148,126L147,127L146,127L146,128L146,128L146,129L145,129" stroke-opacity="1" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" transform="matrix(1,0,0,1,0,0)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); stroke-opacity: 1; stroke-linecap: round; stroke-linejoin: round;"></path></svg>

1 个答案:

答案 0 :(得分:0)

一些想法......

你的ImageMagick已经过时了,即使没有+antialias,也可以使用版本:ImageMagick 6.9.1-10。

我使用的是rsvg代理而不是svg代理 - 我不确定这是否会产生影响。

enter image description here

如果由于某种原因无法升级,可以使用以下内容清理图像:

convert http://i.cubeupload.com/phlIj0.png -fill white -fuzz 50% -opaque gray result.png