Search code examples
svgimagemagickubuntu-serverubuntu-22.04

SVG 1.2 rasterizing via ImageMagick: vector-effect issue


I've noticed different behavior of ImageMagick CLI utility convert of the same version, but on different versions of Ubuntu 22.04: desktop and docker container.

I want to render SVG utilizing SVG 1.2 attribute vector-effect="non-scaling-stroke":

<svg xmlns="http://www.w3.org/2000/svg"
    width="200"
    height="200"
>
    <g
        x="0"
        y="0"
        transform="scale(4)"
    >
        <rect
            x="25"
            y="25"
            width="50"
            height="50"
            fill="#0cc"
            stroke="black"
            stroke-width="2"
            vector-effect="non-scaling-stroke"
        ></rect>
    </g>
</svg>

I run next command within bash both on Xubuntu Desktop 22.04 and Ubuntu 22.04 server:

convert test.svg test.png

and I get expected result on Xubuntu 22.04 Desktop:

Desktop output - there are thin, non-scaled stroke and also transparent background.

But I get lack of vector-effect applying on Ubuntu 22.04 server within Docker container:

Server output - there are thick scaled stroke and force filled background.

Both system have the same ImageMagick version:

convert --version
Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25

I need to force server version of ImageMagick to take vector-effect="non-scaling-stroke" into account.


Solution

  • The issue is likely which SVG renderer you are using on your two Imagemagick systems. It could be Imagemagick's internal MSVG/XML renderer, RSVG delegate or Inkscape if Inkscape is installed on the system (where IM can find it) all in order of increasing quality of the render. Check which is being used possibly by add -verbose to your command line.