1

ImageMagick (バージョン: ImageMagick 6.9.1-7 Q16 x86_64) とその PHP 拡張 Imagick を LAMP スタックで使用して SVG を JPEG に変換していますが、SVG にテキスト (12-13) が含まれていると、異常に長い時間がかかります。秒/ファイル)。

同じことをコマンド ラインから (または IM の変換を直接使用して) スタンドアロンの PHP スクリプトとして実行すると、テキストの有無に関係なく、1 秒未満ですばやく変換されます。

また、GraphicsMagick ではこの問題が発生しないことも特筆に値します。(ただし、未解決の SVG バグがいくつかあり、使用できません。)

LAMP スタックでのフォントの処理に時間がかかる理由、またはスローダウンの根本原因を特定する方法について、誰かが考えているでしょうか?

サンプル SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"     xmlns:xlink="http://www.w3.org/1999/xlink" width="344" height="243"  viewBox="0 0 737 521">
<g class="main">
    <title>Main</title>
    <image xmlns:xlink="http://www.w3.org/1999/xlink" id="svg_12"  height="218.4417" width="291.2556" y="32.2537" x="-10.893" xlink:href="/tmp/767756670842438737_7032fbfb3c364e6da226254687eb1edb.jpg" style="pointer-events:inherit">29.75235 32.253654 209.964875 218.441697</image>
    <g font-size="normal" font-family="Allerta" class="textarea" id="svg_13" style="pointer-events:inherit">
        <rect opacity="0" fill-opacity="0" stroke-opacity="0" stroke-width="2" fill="#000" id="svg_10" height="32" width="150.4384" y="293.06824" x="550.14683" style="pointer-events:inherit"/>
        <text text-anchor="start" xml:space="preserve" fill="#000" font-size="21" y="293" x="550" id="svg_68" style="pointer-events:inherit">
            <tspan dy="14" x="550" xml:space="preserve" id="svg_69" style="pointer-events:inherit">
        hello </tspan>
            <tspan dy="21" x="550" xml:space="preserve" id="svg_70" style="pointer-events:inherit">gc </tspan>
        </text>
    </g>
</g>
</svg>

および変換するコード:

$im = new Imagick(); 
$svg = file_get_contents($svgFile); 
$svg = str_replace(array("\n", "\r", "\t"), '', $svg); 
$im->readImageBlob($svg); 
$im->setImageFormat("jpeg"); 
$im->writeImage($jpgFile); 
$im->clear(); 
4

1 に答える 1