PNG from SVG with PHP

Because of the lack of support for SVG in current web browsers we need a solution for showing the users the icons within our project MAP-it.

The default GD library doesn’t support the SVG graphic format. We had to turn to Image Magick. If you are not allowed to execute on your webserver you can’t use the Image Magick Library from Linux. But you can always ask your webhost to install the iMagick php library which offers the same functionality without requiring exec() rights. Continue reading

Advertisements

Export SVG from Raphael JS to create a PNG bitmap

Update

I’m very pleased to be able to say that Jonathan Spies has taken the roots of this blog post and produced a fully fledged plugin. I’ve used it on a couple of projects already. Oh how I love the web sometimes.

http://github.com/jspies/raphael.serialize

Introduction

I’ve been playing around with RaphaelJS recently (if you haven’t seen it, check it out) for an ‘avatar builder’ type project to avoid the use of Flash. It’s a really fun bit of kit to use, but I needed a way to actually save the results of the avatar to a bitmap to avoid having heavy javascript libraries every time the avatar is displayed on a page. After a bit of poking around on forums/blogs I thought I’d tie up all the key pieces in one blog post in case anyone else was in the same boat.

The output is essentially a PNG-24 alpha channel bitmap image, which can then be treated as normal with the likes of ImageMagick (I’ve been adding drop shadows to the avatars for example). Continue reading