Page 1 of 1

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

Posted: 2017-01-30T10:02:09-07:00
by thomastc
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.