Reputation: 7426
I have PHP code running on Debian stretch with ImageMagick. It tries to convert SVG to another format. Here is how it starts
$im = new Imagick();
$im->readImageBlob($svg);
The variable $svg
contains valid SVG code in a string. If I copy this string to a text file with a .svg
extension then it opens just fine. But readImageBlob
throws an exception saying no delegate for this image format
.
I have seen similar questions solved by installing more packages to the system. But I've already installed libxml2-dev
, librsvg2-bin
, libmagickcore-6.q16-3-extra
and libfreetype6-dev
.
I have no idea what else I am missing.
Upvotes: 1
Views: 1472
Reputation: 53089
What do you get from running the following command from PHP exec()
convert -list format
The line SVG should say RSVG or MSVG/XML. Does it show that? if you need RSVG, you will have to install that delegate and then reinstall Imagemagick so that Imagemagick can find it. Imagemagick is used by Imagick. They are not the same. The RSVG delegate can be found by a Google Search or from linuxfromscratch.org/blfs/view/svn/general/librsvg.html. Your svg file seems to render properly for me in Imagemagick using RSVG, but I am not sure what it should look like. It is just a graph set of horizontal lines.
I do not know much about using readImageBlob(). Just use readImage(), where you supply the path to a saved svg image file. That should work. Try that and see what you get.
Here is what I get using RSVG 2.42.2 in Imagemagick 6.9.10.3 Q16 Mac OSX were I have saved your text in a file called test.svg.
convert test.svg test.png
If I force the use of the Imagemagick MSVG/XML, it does not look as good.
convert MSVG:test.svg test2.png
Upvotes: 1
Reputation: 7426
I had to prepend the $svg
with <?xml version="1.0" ?>
and it worked. It least it does read in the SVG and attempts to create png/jpeg. One piece of text gets misplaced during convertion though. So the task in general is still failed. But this is another issue. I think the question is answered.
Upvotes: 2