Page 1 of 1

PAID: Need help converting SVG to PNG with IMagick

Posted: 2015-12-03T11:48:25-07:00
by pfriedl
Please see my previous post here:
viewtopic.php?t=28725

We've got most of the code done, but we're having an issue with IMagick/ImageMagick shifting grouped items in an SVG down and to the right. The codebase is php 5.5+ on a CentOS server. ImageMagick 6.9.2-4 Q16 x86_64 2015-10-19 and IMagick 3.1.2.

You can send a PM through the board o email me at pfriedl_at_gmail.com. Thanks!

Re: PAID: Need help converting SVG to PNG with IMagick

Posted: 2015-12-03T13:24:46-07:00
by dlemstra
I am pretty sure that you are using msvg (The svg reader of ImageMagick) instead of inkscape. When I convert your file and force ImageMagick to use msvg I get the same result. When I use rsvg (The windows default) it produces the result that you want. I just did a quick search online and it turns out that IMagick uses a delegates.xml file in php.5.5.X/ext/imagick. Can you check if you have a delagates.xml file for IMagick and is it configured to use inkscape instead of msvg?

Re: PAID: Need help converting SVG to PNG with IMagick

Posted: 2015-12-03T14:16:59-07:00
by pfriedl
Hmmm, I was under the impression that ImageMagick would default to inkscape if inkscape was installed. I have verified that inkscae is installed and working on the server, but I wasn't aware that I needed a delegates.xml. I'll definitely check...

I ran the command "convert -list delegate", and it looks like it's still using rsvg: svg => "rsvg-convert" -o "%o" "%i"

To change to inkscape, what does this need to be changed to?

Thanks for the help on this - I've been tearing my hair out trying to figure this out!

Re: PAID: Need help converting SVG to PNG with IMagick

Posted: 2015-12-03T14:25:07-07:00
by dlemstra
You will probably get the correct result with rsvg on the command line. But IMagick will not execute the convert command. I am not a php/imagick expert so I don't know where the delegates.xml file is located.

Re: PAID: Need help converting SVG to PNG with IMagick

Posted: 2015-12-03T14:39:01-07:00
by pfriedl
Thanks for the fast reply.

I won't be able to use command line as this is running in a web app (not command line, but on an automated, bulk scale) and I'm using IMagick and an instance of an ImageMagick object in the code so I can build composite images after converting the SVG.

So do I need to change the svg handler in the delegates.xml file to inkscape, and if so, how?

Re: PAID: Need help converting SVG to PNG with IMagick

Posted: 2015-12-03T14:50:23-07:00
by dlemstra
Do you have a delegates.xml file in the imagick php folder on your system? Copying the delegates.xml file from your home directory to that php folder will tell it to use rsvg instead of msvg. That should produce the correct imge. But if you want to use inkscape you will need to change the svg:decode delegates. You can find an example here: http://stackoverflow.com/questions/1132 ... magemagick

Re: PAID: Need help converting SVG to PNG with IMagick

Posted: 2015-12-03T15:01:39-07:00
by fmw42
Why can you not just put the Imagemagick command line in a PHP exec() command? It runs just as good as Imagick and has more flexibility in terms of Imagemagick functionality.