node-svg2img
v1.1.0
Published
convert svg to image(png/jpeg) for nodejs
Downloads
209
Readme
SVG to PNG/JPEG based on fabric
To convert to JPEG, you must build node-canvas with jpeg support.
Install
npm install --save node-svg2img
Usage
var fs = require('fs');
var svg2img = require('node-svg2img');
// var input = Buffer.from(...);
// var input = '<svg>...</svg>';
// var input = 'data:image/xml+svg;base64,...';
// var input = 'http://url.to/a.svg';
var input = 'src.svg';
svg2img(input, { format: 'png', width: 200, height: 200 }, function (err, data) {
fs.writeFileSync('dest.png', data);
});
Options
format
: output format, default to 'png', otherwise 'jpg/jpeg'width
: set output width, default to original widthheight
: set output height, default to original height