I need to convert SVG XML to a PNG using PHP without anything like ImageMagick that requires installation on the server. I know this has been asked once before, but there wasn't an answer that fits this. Is it possible to do this?
Asked
Active
Viewed 3,106 times
3
-
1PHP has **NO** native image handling capabilities. Unless you want to write your own rasterizer to convert svg vector -> png rasters, you're stuck with external libraries, e.g. imagick – Marc B Nov 22 '13 at 14:40
-
2You would have to parse the XML and convert it to a png. Therefore you could begin to parse the SVG ( [loop through xml](http://stackoverflow.com/questions/16226736/loop-through-svg-elements-with-php)) and write a PNG. I think you'd be better off, if you would create an external webservice that accepts SVG and serves PNG with imagemagick, inkscape or rsvg. – pce Nov 22 '13 at 14:51
-
@Marc B - GD? GD2? Sure, neither do SVG - but no native graphics? Not true. – Michael Jan 13 '14 at 15:47
-
@michael: that's not "native". It's an optional module that does tend to be available in most places. – Marc B Jan 13 '14 at 16:21
1 Answers
2
If you do not already have IMagick or MagicWand built in PHP then there is nearly no chance. You could write a SVG parser and PNG writer by your own what would be no fun - i promise.

l-x
- 1,521
- 9
- 17