Node.JS Binding for LibRSVG
LibRSVG is a SVG rendering library, which parses SVG files and renders them in various formats. The formats include:
- PNG
- PDF
- SVG
- Raw memory buffer image
Basic Usage
Here is a simple example. Look in index.js
for more documentation.
var Rsvg = require('rsvg').Rsvg;
var fs = require('fs');
var svg = new Rsvg();
svg.on('finish', function() {
console.log('SVG width: ' + svg.width);
console.log('SVG height: ' + svg.height);
fs.writeFile('tiger.png', svg.renderPNG(600, 400).data);
});
fs.createReadStream('tiger.svg').pipe(svg);
Installation
First install the LibRSVG library and header files. Usually you have to look for a development package version. You must also have a functioning build tool chain including pkg-config
. You can find instructions for different operating systems below. After that, you simply run:
npm install rsvg
Library versions known to work:
- LibRSVG 2.26+
- Cairo 1.8.8+
Ubuntu:
sudo apt-get install librsvg2-dev
RedHat / OpenSUSE:
sudo yum install librsvg2-devel
Mac OS X:
brew install librsvg
Windows:
N/A; pull requests are accepted!