0

I am trying to convert svg to png image using imagick but it is showing blank, my code for imagick is

<?php
$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));
$svg = file_get_contents("new_old.svg");
$im->readImageBlob($svg);

$im->setImageFormat("png32");

header('Content-type: image/png');

echo $im;
?>

and code for my svg image is

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="282" height="504" xmlns:xlink="http://www.w3.org/1999/xlink">
<image id="4" preserveAspectRatio="none" x="27" y="132" width="238" height="453" xlink:href="http://asia.olympus-imaging.com/products/dslr/e520/sample/images/thumb_01.jpg"/>
</svg>

Can anyone provide solution for these problem.

Mukesh
  • 7,630
  • 21
  • 105
  • 159

1 Answers1

0

Just a quick guess you have to set the DPI

<?php
$im = new Imagick();
$im->setResolution(300, 300); // for 300 DPI example

More info: http://www.php.net/manual/en/imagick.setresolution.php#95533

the JinX
  • 1,950
  • 1
  • 18
  • 23