/gulp-raster

gulp task for conversion svg to raster

Primary LanguageJavaScriptMIT LicenseMIT

gulp-raster

NPM version Dependency Status

Rasterization plugin for gulp. It`s build on phantomjs and looks pretty much like svg2png, but output file content instead of saving it to disk.

Usage

First, install gulp-raster as a development dependency:

npm i -D gulp-raster

Then, add it to your gulpfile.js:

var raster = require('gulp-raster');
var rename = require('gulp-rename');

gulp.src('./src/**/svg/*.svg')
    .pipe(raster())
    .pipe(rename({extname: '.png'})
    .pipe(gulp.dest('./dist')),

You also can specify scale and file format. Let`s say you want get icon set for retina:

var raster = require('gulp-raster');
var rename = require('gulp-rename');

gulp.src('./src/**/svg/*.svg')
    .pipe(raster({format: 'jpg', scale: 2}))
    .pipe(rename({extname: '.jpg', suffix: '-2x'})
    .pipe(gulp.dest('./dist')),

API

raster(options)

options.scale

Type: Number Default: 1

Set scale rate of output image.

options.format

Type: String Default: png

Set output file format, png/jpg are available.

License

MIT License