$svg = __DIR__ . '/scheme.svg';
$imagic = new Imagick();
$imagic->readImageBlob(file_get_contents($svg));
$imagic->setImageFormat("png24");
header('Content-Type: image/png');
echo $imagic;
$imagic->clear();
$imagic->destroy();
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="600" height="400" viewBox="0 0 600 400" xmlns="http://www.w3.org/2000/svg" version="1.1">
<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="flat.png" x="0" y="0" width="600" height="400"/>
<text y="0" font-size="15" class="complex-text" text-anchor="middle" transform="matrix(1 0 0 1 219.375 156.875)">
<tspan x="0" dy="">Общая</tspan>
<tspan x="0" dy="16.5">комната</tspan>
<tspan x="0" dy="16.5">15.81м²</tspan>
</text>
<text y="0" font-size="15" class="complex-text" text-anchor="middle" transform="matrix(1 0 0 1 373.125 189.375)">
<tspan x="0" dy="">Кухня</tspan>
<tspan x="0" dy="16.5">8.28 м²</tspan>
</text>
</svg>
$svg = __DIR__ . '/scheme.svg';
$svg_blob = file_get_contents($svg);
$absolute_path = __DIR__;
$svg_blob = preg_replace_callback('/<image xlink:href="([^"]+)"/i', function($match, $a, $b) use ($absolute_path) {
$path_to_image = $absolute_path . '/' . $match[1];
$image_base64 = base64_encode(file_get_contents($path_to_image));
list($w, $h, $type) = getimagesize($path_to_image);
switch ($type) {
case IMAGETYPE_PNG:
$type = 'image/png';
break;
case IMAGETYPE_JPEG:
$type = 'image/jpeg';
}
return "<image xlink:href=\"data:$type;base64,$image_base64\"";
}, $svg_blob);
$imagic = new Imagick();
$imagic->readImageBlob($svg_blob);
$imagic->setImageFormat("png24");
header('Content-Type: image/png');
echo $imagic;
$imagic->clear();
$imagic->destroy();
<pattern id="kitchen_washbasin_pattern" patternUnits="userSpaceOnUse" x="579" y="187" width="100%" height="100%">
<image xlink:href="/images/skinali/kitchen_elem_06.png" width="170" height="172"></image>
</pattern>
<image xlink:href="/images/skinali/kitchen_elem_06.png" width="170" height="172" x="579" y="187"></image>