gulp-raster

0.2.0 • Public • Published

gulp-raster

NPM version Dependency Status

Rasterization plugin for gulp. It`s build on phantomjs, but, in contrast to svg2png, does not deal with fs(creating or reading tmp files).

Usage

First, install gulp-raster as a development dependency:

npm i -S 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

Package Sidebar

Install

npm i gulp-raster

Weekly Downloads

141

Version

0.2.0

License

none

Last publish

Collaborators

  • otouto