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.
Post Reply
rdb2b
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 »

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
Post Reply