I have the XML for an SVG, but I'm struggling to understand how I can manipulate it so I can change its colour/add it as a layer to a greater Imagick object.
I can do readImageBlob and then echo out the results, and see my SVG just fine. But when I use http://php.net/manual/en/imagickdraw.se ... aphics.php (which I'm only assuming does what I am expecting) I get an error stating that imagick cannot draw this layer.
Here is the code which I have:
Code: Select all
$height = 520; $width = 820; $backgroundColour = "blue"; $im = new Imagick(); $im->newImage( $width, $height, new ImagickPixel( $backgroundColour ) ); $svg = $this->svgXML; $draw = new ImagickDraw(); $draw->setVectorGraphics($svg); $im->drawImage( $draw ); $im->setImageFormat( "png" ); echo '<img src="data:image/png;base64,'.base64_encode($im->getImageBlob()).'" alt="" class="renderedImage" />';
As mentioned earlier, I doubt setVectorGraphic is the correct function to allow the SVG to pass to drawImage (seeing as no matter what I do, it fails), so if there is a better way to do this, which will allow me to manipulate it better, then I am all ears!