svgimagemagickpngmix-blend-mode

Will ImageMagick SVG to PNG conversion respect blend modes?


Does ImageMagick have the capability to handle SVG blend modes? When converting an SVG to PNG, for example?

Using ImageMagick-7.0.8-Q16, Inkscape 0.92.1 r15371

I have a simple SVG with two rectangles, red and blue, and a mix-blend-mode of "exclusion" on the blue. It appears as expected on any browser I've tried (see the MS Edge sshot)

Inkscape will convert the SVG image to a PNG correctly, respecting the mix blend mode style. However, ImageMagick, does not (see results.png). ImageMagick seems to just use "normal" mix-blend-mode (FWIW, IMDisplay shows the same icorrect image, blend mode ignored)

Is there some option that I need to change? Or, if ImageMagick just does not handle SVG blending modes, is there some plan to have it do so in the future?

My command lines are as follows:

inkscape test.svg -e Inkscape.png
magick test.svg IMagick.png

The SVG file contains only:

<svg width='300' height='300' xmlns = 'http://www.w3.org/2000/svg' 
     xmlns:xlink='http://www.w3.org/1999/xlink'>
<rect width='100%' height='100%' fill='#dddddd'/>
<rect x='50'  y='50' width='150' height='150' style='fill:red;' />
<rect x='100' y='100' width='150' height='150' 
      style='fill:blue;mix-blend-mode:exclusion' />
</svg

results


Solution

  • Looks like ImageMagick is using its internal MVG decoder. Make sure that the delegates.xml file has inkscape instructions for the svg:decode, and such a command works as expected.

    Something like:

    <delegate decode="svg:decode" stealth="True" command="&quot;inkscape&quot; &quot;%s&quot; --export-file=&quot;%s&quot; --export-dpi=&quot;%s&quot; --export-background=&quot;%s&quot; --export-background-opacity=&quot;%s&quot; &gt; &quot;%s&quot; 2&gt;&amp;1"/>
    

    You can verify the correct command is being used with a -verbose option.

    magick -verbose test.svg IMagick.png