问题
I'm trying to convert svg image to png with the following code:
$image = new Imagick();
$image->readImageBlob($_POST['svgcode']);
$image->setImageFormat("png24");
$image->resizeImage(600, 600, imagick::FILTER_LANCZOS, 1);
header('Content-type: image/png');
echo $image;
But there is an error in the second line:
NoDecodeDelegateForThisImageFormat `' @ error/blob.c/BlobToImage/361
How can I fix this?
回答1:
First line of your svg must be <?xml version="1.0" encoding="UTF-8" standalone="no"?>
$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg;
Do it and you will be enjoying :-)
回答2:
This post helped me a lot http://www.elxsy.com/2009/07/installing-imagemagick-on-windows-and-using-with-php-imagick/
To be exact this piece:
This is the important part, I spent good half an hour trying to make it work.. grrrr.. You need to restart your PC to libraries take effect.
Never did this for installing php extensions.
来源:https://stackoverflow.com/questions/18661811/why-do-i-get-nodecodedelegateforthisimageformat-when-rastering-svg-to-png-with-i