SVG to PNG conversion transparent background
Posted: 2009-08-05T16:32:24-07:00
Would really appreciate some help on this one please. I think should work, but I am still getting a white background.
I have tested the following which creates a new image and it works fine, so it has something to do with creating a new image versus reading in an SVG, but I can't figure out what.
Thanks for any ideas,
Adrian
Code: Select all
$imagickImage = new Imagick();
$imagickImage->readImage($path_to_svg);
$imagickImage->setImageBackgroundColor(new ImagickPixel("transparent"));
$imagickImage->setImageFormat("png32");
$imagickImage->writeImage($path_to_png);
$imagickImage->clear();
$imagickImage->destroy();
Code: Select all
$imagickImage = new Imagick();
$imagickImage->newImage(100, 100, new ImagickPixel("orange"));
$imagickImage->setImageBackgroundColor(new ImagickPixel("transparent"));
$imagickImage->waveImage(15, 200);
$imagickImage->trimImage(0);
$imagickImage->setImageFormat("png32");
$imagickImage->writeImage($path_to_png);
$imagickImage->clear();
$imagickImage->destroy();
Adrian