Home > Back-end >  Imagick not detecting inkscape
Imagick not detecting inkscape

Time:10-30

after compiling and installing imagick for php8 (and working through the problems that causes to occur), I can now convert svgs to images. However, after installing inkscape and checking the delegations for imagick, imagick is not detecting and using inkscape. without any further errors to work through, and after going through plenty of google pages, I am convinced I either missed something that should be installed or configured, or I plainly did something wrong. I would appreciate any directions and/or assistance.

below you'll find information regarding versions, code and configurations, if anything else is required, please ask and I'm happy to provide.

grepping SVG renderers using convert -list format | grep SVG gives me the 3 basic renderers (MSVG, SVG and SVGZ).

The php code used to render the final image is pretty basic and should not be related to the issue at hand, but here it is anyway:

class SvgRenderer
{

    private static ?Crop $_crop = null;
    private static Imagick $_im;

    // ...

    public static function stringToPng32($svg)
    {

        self::$_im = new Imagick();
        self::$_im->setFont('../fonts/arial.ttf');
        self::$_im->readImageBlob($svg);
        self::$_im->setImageFormat('png32');

        if(self::$_crop !== null) self::_applyCrop();
        return self::$_im->getImageBlob();

    }

    // ...

}

The versions of php, inkscape and imagick are:

PHP: 8.0.9

Inkscape: 0.92.2

Imagick: 7.1.0-0

svg delegate rules:

<delegate decode="svg" command="&quot;@RSVGDecodeDelegate@&quot; -o &quot;%o&quot; &quot;%i&quot;"/>
<!-- Change export-filename to export-png for inkscape < 1.0 -->
<delegate decode="svg:decode" stealth="True" command="&quot;@SVGDecodeDelegate@&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"/>

The first image is rendered locally using imagick and inkscape, the second one is rendered on a server running the exact same code.

expected result: enter image description here

current result: enter image description here

CodePudding user response:

After even more searching, I finally found what caused the issue... Inkscape 0.92 is the latest build for centos (not counting snap or other sandbox builds), which doesn't work with ImageMagick 7.0 downgrading to 6.9.33 fixed the issue.

  • Related