![](https://secure.gravatar.com/avatar/8d5128b5b838ecedc34635fba7995f7f.jpg?s=120&d=mm&r=g)
On Wed, Mar 28, 2007 at 06:44:45PM +0200, vin@...1705... wrote:
Hello Inkscape developers!
Great work :)
I love svg & inkscape, and I'm currently playing with dynamically altering svgs (created with inkscape) under php. Now i am facing the problem of converting these svgs to raster graphics (png, jpg) using only php and gd on a web server.
I googled but did not find any approach in this direction. There is a gd extension for creating svgs from gd commands, but not the other way round.
Anyone know a possibility of doing this?
If there really is no such library yet, I am ready to take a stab at it myself. Do you think porting some inkscape code to php (of course preserving the GNU license) is a manageabel and promising approach?
I'd be grateful for any comments, links or reccomendations.
I've experimented around with a number of different approaches for doing this, each with their pluses and minuses.
As others pointed out, inkscape can be run from the commandline. This gives good quality results, and there's few problems with stuff that doesn't render. It does have a number of commandline options for controlling what gets exported. The downside is that inkscape isn't a very lightweight solution.
Cairo has an svg2png tool that is quite lightweight, and supports most of Inkscape's SVG features, but there might be some minor rendering discrepancies.
Imagemagick is a good choice for server-side image processing. It has some support for SVG, but I wasn't that impressed with it; it supports a subset of available SVG features.
I haven't played with gd's svg support, but expect it'd be on the level of imagemagick; possibly it uses the same backend for svg processing.
For manipulating the SVG content itself, depending on your needs, most likely what you'll want is php's xpath library rather than the above renderers. There are some SVG manipulation libraries, though I haven't heard of one for PHP.
Hoep this helps, Bryce