gulp-rsvg

Convert SVG to PNG or PDF.

gulp-rsvg

Convert SVG to PNG or PDF.

If you have any difficulties with the output of this plugin, please use the RSVG tracker.

Install via npm:

npm install gulp-rsvg --save-dev

Note that this plugin wraps node-rsvg and so requires LibRSVG to be available on the command line. Please see the README for node-rsvg for a guide on how to set that up for your platform.

var gulp = require('gulp');
var convert = require('gulp-rsvg');
 
gulp.task('png', function() {
    return gulp.src('logo.svg')
        .pipe(convert())
        .pipe(gulp.dest('./out'));
});
 
gulp.task('pdf', function() {
    return gulp.src('logo.svg')
        .pipe(convert({
            format: 'pdf'
        }))
        .pipe(gulp.dest('./out'));
});

Type: String Default value: png

The format to convert to. Accepts png or pdf.

Type: Integer Default value: undefined

Specify a new width for the resulting file. Defaults to the width of the SVG.

Type: Integer Default value: undefined

Specify a new height for the resulting file. Defaults to the height of the SVG.

Type: Integer Default value: 1

Scale the generated file by this factor. Useful for retina assets.

Type: Function Default value: require('librsvg').Rsvg

Pass a svg rendering library. Rsvg by npm package librsvg used by default.

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

MIT © Ben Briggs