Skip to content

Otouto/gulp-raster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

gulp task for conversion svg to raster

Resources

License

Stars

Watchers

Forks

Packages

No packages published