0

I'am trying to convert an SVG Image which is created by the SVGGraph library ( http://www.goat1000.com/svggraph.php).

The SVG is colored (red, green, yellow, gray, ...) in the browser and everything is fine. But when I convert it, its just black and white.

With this code I convert it:

//new instance of imagick
$im = new Imagick();
//read the svg file/data (its not saved on the filesystem)
$im->readImageBlob($svgFile);

$im->setImageFormat("png24");
$im->writeImage('cylinder.png');
$im->clear();
$im->destroy();

I've tried it with jpeg and png as output format but the result is the same, all colors will be replaced with black

does anyone have an idea how to fix that ?

oneandonlycore
  • 480
  • 6
  • 23
  • I am not familiar with SVGGraph but did you check to see if the SVG file is 100% valid? Also, check http://stackoverflow.com/questions/4809194/convert-svg-image-to-png-with-php, it might give you ideas. – Technoh Aug 27 '13 at 12:21

1 Answers1

0

Try this way:

$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));
$im->readImageBlob($svgFile);

$im->setImageFormat("png24");
$im->writeImage('cylinder.png');
$im->clear();
$im->destroy()
Manolo
  • 24,020
  • 20
  • 85
  • 130