SVG to PNG conversion giving me blank png image

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Posts: 1
Joined: 2015-05-26T04:21:42-07:00
Authentication code: 6789

SVG to PNG conversion giving me blank png image

Post by rdb2b »


I have a SVG image on this path ... -saved.svg

Which i need to convert into PNG for which i am using below code on this php file

Code: Select all

$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;

/*png settings*/


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

echo $im;

If i remove the line $svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg; Then it gives fatal error as on

Can anyone please help me how to convert this svg image ... -saved.svg to PNG image using PHP.

Any help would be appreciated.