I am trying to dynamically generate images from svg files using imagemagick and the imagick wrapper, but the converted png's always have white backgrounds rather than transparent. Does anyone know how to make them transparent without having to erase all the white areas?
Heres my code
PHP Code:$im = new Imagick();
$svg = file_get_contents("design.svg");
$svg = str_replace(array("color1","color2"),array("red","lightblue"),$svg);
$im->readImageBlob($svg);
$im->setImageBackgroundColor(new ImagickPixel('transparent'));
$im->setImageFormat("png24");
header("Content-Type: image/png");
echo $im;


Reply With Quote

Bookmarks