Imagick не корректно конвертирует из svg в jpeg или png

128
21 августа 2021, 18:50

Создаю svg:

<svg width="400" height="400" viewBox="-30 -40 336.6666666666667 296.6666666666667" id="maker-svg" style="padding: 10px;" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="13.333333333333334" stroke="#03a9f4" stroke-width="0.5mm" fill="rgba(3, 169, 244, 0.1)" style="stroke:#03a9f4;stroke-width:0.5mm;fill:rgba(3, 169, 244, 0.1)"><g id="0"><g id="0"><g id="trapeze"><line id="ab" data-route="[&quot;models&quot;,&quot;0&quot;,&quot;models&quot;,&quot;trapeze&quot;,&quot;paths&quot;,&quot;ab&quot;]" x1="23.333" y1="0" x2="223.333" y2="100" vector-effect="non-scaling-stroke"></line><line id="bc" data-route="[&quot;models&quot;,&quot;0&quot;,&quot;models&quot;,&quot;trapeze&quot;,&quot;paths&quot;,&quot;bc&quot;]" x1="223.333" y1="100" x2="223.333" y2="200" vector-effect="non-scaling-stroke"></line><line id="cd" data-route="[&quot;models&quot;,&quot;0&quot;,&quot;models&quot;,&quot;trapeze&quot;,&quot;paths&quot;,&quot;cd&quot;]" x1="223.333" y1="200" x2="173.333" y2="200" vector-effect="non-scaling-stroke"></line><line id="da" data-route="[&quot;models&quot;,&quot;0&quot;,&quot;models&quot;,&quot;trapeze&quot;,&quot;paths&quot;,&quot;da&quot;]" x1="173.333" y1="200" x2="23.333" y2="0" vector-effect="non-scaling-stroke"></line></g></g><g id="gray" stroke="gray" style="stroke: gray; fill: none;"><g id="LineL_lp"><line id="line_L" data-route="[&quot;models&quot;,&quot;LineL_lp&quot;,&quot;paths&quot;,&quot;line_L&quot;]" x1="23.333" y1="235" x2="223.333" y2="235" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="LineL1_lp"><line id="line_L1" data-route="[&quot;models&quot;,&quot;LineL1_lp&quot;,&quot;paths&quot;,&quot;line_L1&quot;]" x1="173.333" y1="210" x2="223.333" y2="210" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="LineH_lp"><line id="line_H" data-route="[&quot;models&quot;,&quot;LineH_lp&quot;,&quot;paths&quot;,&quot;line_H&quot;]" x1="13.333" y1="200" x2="13.333" y2="0" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="LineH1_lp"><line id="line_H1" data-route="[&quot;models&quot;,&quot;LineH1_lp&quot;,&quot;paths&quot;,&quot;line_H1&quot;]" x1="233.333" y1="200" x2="233.333" y2="100" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line0_hl"><line id="line_0" data-route="[&quot;models&quot;,&quot;Line0_hl&quot;,&quot;paths&quot;,&quot;line_0&quot;]" x1="23.333" y1="0" x2="23.333" y2="235" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line1_hl"><line id="line_1" data-route="[&quot;models&quot;,&quot;Line1_hl&quot;,&quot;paths&quot;,&quot;line_1&quot;]" x1="223.333" y1="200" x2="223.333" y2="235" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line2_hl"><line id="line_2" data-route="[&quot;models&quot;,&quot;Line2_hl&quot;,&quot;paths&quot;,&quot;line_2&quot;]" x1="173.333" y1="200" x2="13.333" y2="200" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line3_hl"><line id="line_3" data-route="[&quot;models&quot;,&quot;Line3_hl&quot;,&quot;paths&quot;,&quot;line_3&quot;]" x1="23.333" y1="0" x2="13.333" y2="0" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line4_hl"><line id="line_4" data-route="[&quot;models&quot;,&quot;Line4_hl&quot;,&quot;paths&quot;,&quot;line_4&quot;]" x1="173.333" y1="200" x2="173.333" y2="210" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line5_hl"><line id="line_5" data-route="[&quot;models&quot;,&quot;Line5_hl&quot;,&quot;paths&quot;,&quot;line_5&quot;]" x1="223.333" y1="200" x2="223.333" y2="210" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line6_hl"><line id="line_6" data-route="[&quot;models&quot;,&quot;Line6_hl&quot;,&quot;paths&quot;,&quot;line_6&quot;]" x1="223.333" y1="200" x2="233.333" y2="200" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g><g id="Line7_hl"><line id="line_7" data-route="[&quot;models&quot;,&quot;Line7_hl&quot;,&quot;paths&quot;,&quot;line_7&quot;]" x1="223.333" y1="100" x2="233.333" y2="100" stroke="gray" style="stroke:gray" vector-effect="non-scaling-stroke"></line></g></g><g id="captions"><text alignment-baseline="middle" text-anchor="middle" transform="rotate(0,123.333,248.333)" x="123.333" y="248.333" style="stroke: none; fill: black;">L: 200</text><text alignment-baseline="middle" text-anchor="middle" transform="rotate(0,198.333,223.333)" x="198.333" y="223.333" style="stroke: none; fill: black;">L1: 50</text><text alignment-baseline="middle" text-anchor="middle" transform="rotate(270,0,100)" x="0" y="100" style="stroke: none; fill: black;">H: 200</text><text alignment-baseline="middle" text-anchor="middle" transform="rotate(270,246.667,150)" x="246.667" y="150" style="stroke: none; fill: black;">H1: 100</text></g></g></g></svg>

Конвертирую:

$imagick = new \Imagick();
$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . (ShapeController::getShapeParametersOnObject($shape->parameters))->svg->value;
$imagick->readImageBlob($svg);
$imagick->setImageFormat("png");
$imagick->adaptiveResizeImage(400, 400);
$jpeg = $imagick->getImagesBlob();

На выходе:

Что за я забыл или не правильно указал? Или чего-то не понимает Imagick?

READ ALSO
Упростить код на PHP

Упростить код на PHP

Как бы упроситить вот такой кодСлишком много повторов

140
session сбрасывается после перезапуска браузера (моб) php

session сбрасывается после перезапуска браузера (моб) php

Подскажите пожалуйста, есть такой код авторизации на сайте

133
htmlentities() expects parameter 1 to be string, array given

htmlentities() expects parameter 1 to be string, array given

День добрыйОбновляю Laravel и ловлю эту ошибку (ErrorException in helpers

221
Рекурсивный вариант array_change_key_case

Рекурсивный вариант array_change_key_case

Есть ли вариант функции array_change_key_case(), работающий со вложенными массивами?

162