SVG conversion output size depends on Inkscape version (96 dpi since Inkscape 0.92)

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
thomastc
Posts: 1
Joined: 2017-01-30T09:53:48-07:00
Authentication code: 1151

SVG conversion output size depends on Inkscape version (96 dpi since Inkscape 0.92)

Post by thomastc » 2017-01-30T10:02:09-07:00

It seems that convert delegates SVG conversions to Inkscape if possible:

Code: Select all

$ convert -verbose input.svg output.png
'inkscape' '/tmp/magick-7021NuwMejdeE5J' --export-png='/tmp/magick-7028UtiZe34gdWV' --export-dpi='90,90' --export-background='rgb(100%,100%,100%)' --export-background-opacity='1' > '/tmp/magick-7024PjbEew5AMM7' 2>&1
The problem is that the latest Inkscape release, 0.92, changed the default DPI from 90 to 96. Previously, in Inkscape 0.91, --export-dpi=90,90 did not do anything; it just converted 1 "SVG unit" to 1 pixel. But with Inkscape 0.92, this actually converts 1 unit into 90/96 pixel, so the output image size is different.

As a temporary workaround that doesn't require me to modify ImageMagick itself, I have found that I can modify /etc/ImageMagick-6/delegates.xml, changing this line:

Code: Select all

<delegate decode="svg:decode" stealth="True" command="&quot;inkscape&quot; &quot;%s&quot; --export-png=&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"/>
... into this:

Code: Select all

<delegate decode="svg:decode" stealth="True" command="&quot;inkscape&quot; &quot;%s&quot; --export-margin=&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"/>
This replaces --export-png by --export-margin. We can't just remove the flag, because there is a fixed series of %s substitutions that should not be messed with. This hack works because --export-margin only applies to PS/EPS/PDF export, and is ignored otherwise.

Using Arch Linux, ImageMagick 6.9.7-5.

Post Reply