tags:

views:

797

answers:

2

I need to convert SVG content to a raster image (preferably a PNG) in a RoR app. Is there a direct method that doesn't involve ImageMagick, or is this the de facto standard?

+1  A: 

Generally, ImageMagick is considered the de facto standard. It's been tied into so many languages by now that it shouldn't even be a hassle to use. The ruby binding seems to be called rmagick.

That said, you could of course load and render the SVG yourself, perhaps with the ruby bindings for librsvg (never used that successfully though), and using ruby-libpng to store it as a png.

What's an RoR app though?

roe
RoR - Ruby on Rails
rslite
doh... I guess I should've known that :)
roe
A: 

some bash scripting from this forum:

using rsvg:

$ cd your-directory-with-the-svgs/
$ for i in *; do rsvg-convert $i -o echo $i | sed -e 's/svg$/png/'; done

using inkscape:

$ cd your-directory-with-the-svgs/
$ for i in *; do inkscape $i --export-png=echo $i | sed -e 's/svg$/png/'; done

pageman