【问题标题】:Imagick not detecting inkscapeimagick没有检测到inkscape
【发布时间】:2021-12-11 18:44:30
【问题描述】:

在为 php8 编译和安装 imagick(并解决导致发生的问题)之后,我现在可以将 svgs 转换为图像。但是,在安装了 inkscape 并检查了 imagick 的委托后,imagick 并没有检测和使用inkscape。没有任何进一步的错误需要解决,并且在浏览了大量的谷歌页面之后,我确信我要么错过了应该安装或配置的东西,要么我明显做错了什么。我将不胜感激任何指示和/或帮助。

您将在下面找到有关版本、代码和配置的信息,如果需要其他任何信息,请询问,我很乐意提供。

使用convert -list format | grep SVG grepping SVG 渲染器为我提供了 3 个基本渲染器(MSVG、SVG 和 SVGZ)。

用于渲染最终图像的 php 代码非常基础,不应该与手头的问题相关,但无论如何:

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();

    }

    // ...

}

php、inkscape、imagick的版本分别是:

PHP:8.0.9

Inkscape:0.92.2

Imagick:7.1.0-0

svg 委托规则:

<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"/>

第一张图片使用 imagick 和 inkscape 在本地渲染,第二张图片在运行完全相同代码的服务器上渲染。

预期结果:

当前结果:

【问题讨论】:

    标签: svg png imagick inkscape


    【解决方案1】:

    经过更多的搜索,我终于找到了导致问题的原因...... Inkscape 0.92 是 centos 的最新版本(不包括 snap 或其他沙盒版本),它不适用于 ImageMagick 7.0+ 降级到 6.9.33 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2011-10-08
      • 2018-11-27
      • 2017-02-05
      • 2014-01-15
      • 2014-08-18
      • 2016-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多