在為 php8 編譯和安裝 imagick(并解決導致發生的問題)后,我現在可以將 svgs 轉換為影像。但是,在安裝inkscape 并檢查imagick 的委托后,imagick 沒有檢測和使用inkscape。沒有任何進一步的錯誤可以解決,并且在瀏覽了大量的谷歌頁面之后,我確信我要么錯過了應該安裝或配置的東西,要么我做錯了什么。我將不勝感激任何指示和/或幫助。
您將在下面找到有關版本、代碼和配置的資訊,如果需要其他任何資訊,請詢問,我很樂意提供。
使用convert -list format | grep SVGgrepping 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
墨景: 0.92.2
想象: 7.1.0-0
svg 委托規則:
<delegate decode="svg" command=""@RSVGDecodeDelegate@" -o "%o" "%i""/>
<!-- Change export-filename to export-png for inkscape < 1.0 -->
<delegate decode="svg:decode" stealth="True" command=""@SVGDecodeDelegate@" "%s" --export-png="%s" --export-dpi="%s" --export-background="%s" --export-background-opacity="%s" > "%s" 2>&1"/>
第一個影像使用 imagick 和inkscape 在本地渲染,第二個影像在運行完全相同代碼的服務器上渲染。
預期結果: 
當前結果: 
uj5u.com熱心網友回復:
經過更多搜索,我終于找到了導致問題的原因... Inkscape 0.92 是centos 的最新版本(不包括 snap 或其他沙箱版本),它不適用于 ImageMagick 7.0 降級到 6.9.33 修復了該問題.
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/343506.html
