Page 1 of 1

SVG to PNG conversion giving me blank png image

Posted: 2015-05-26T04:31:41-07:00
by rdb2b
Hi,

I have a SVG image on this path http://www.quickdesign.com/user-uploads ... -saved.svg

Which i need to convert into PNG for which i am using below code on this php file http://www.quickdesign.com/png.php

Code: Select all

<?php
$svg_file_name = 'user-uploads/5555f546857ce-saved.svg';
$png_file_name = 'png/converted.png';
$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));
$svg = file_get_contents($svg_file_name);
$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg;
$im->readImageBlob($svg);

/*png settings*/
$im->setImageFormat("png32");


$im->writeImage($png_file_name);

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

echo $im;

$im->clear();
$im->destroy();
?>
If i remove the line $svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg; Then it gives fatal error as on http://www.quickdesign.com/png2.php


Can anyone please help me how to convert this svg image http://www.quickdesign.com/user-uploads ... -saved.svg to PNG image using PHP.

Any help would be appreciated.

Thanks