I want to convert SVG into PNG using ImageMagick using PHP. I have installed ImageMagick on XAMPP and verified it using phpinfo(), but still can't generate images. Here is my code:
$svg = file_get_contents($svg_file);
//echo $svg;
$im = new Imagick();
//$im->setBackgroundColor(new ImagickPixel('transparent'));
// $svg = str_replace(array("color1","color2"),array("red","lightblue"),$svg);
$im->readImageBlob($svg);
//$im->setImageFormat("png32");
$im->setImageFormat("png24");
// $im->resizeImage(720, 445, imagick::FILTER_LANCZOS, 1);
// $im->adaptiveResizeImage(720, 445);
$im->writeImage($png_file);
header('Content-type: image/png');
echo $im;
$im->clear();
$im->destroy();