Convert SVG to PNG in Ruby

I need to convert SVG content to a bitmap (preferably PNG) in a RoR application. Is there a direct method that ImageMagick does not include, or is it the actual standard?

+6
ruby png svg
source share
2 answers

ImageMagick is generally considered the de facto standard. To date, he has been attached to so many languages โ€‹โ€‹that he does not even need to be bothered. Ruby binding is apparently called rmagick.

However, you can, of course, load and display the SVG yourself, perhaps with ruby โ€‹โ€‹bindings for librsvg (never used this successfully), and using ruby-libpng to store it as png.

What is a RoR app?

+3
source share

some bash scripts from this forum :

using rsvg :

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

using inkscape :

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

+2
source share

All Articles