Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var responsive = require('gulp-responsive');
- var load = require('gulp-load-plugins')();
- gulp.task('resize-img', function () {
- return gulp.src('img/*.{jpg,png}')
- .pipe(load.responsive({
- '*.jpg': [{
- width: 100,
- rename: {
- suffix: '-thumb',
- }
- }, {
- width: 300,
- rename: {
- suffix: '-medium',
- // extname: '.jpg',
- },
- }, {
- width: 900,
- rename: {
- suffix: '-big',
- },
- // Do not enlarge the output image if the input image are already less than the required dimensions.
- withoutEnlargement: true,
- }],
- '*.png': [{
- width: 100,
- rename: {
- suffix: '-thumb',
- }
- }, {
- width: 300,
- rename: {
- suffix: '-medium',
- // extname: '.jpg',
- },
- }, {
- width: 900,
- rename: {
- suffix: '-big',
- },
- // Do not enlarge the output image if the input image are already less than the required dimensions.
- withoutEnlargement: true,
- }]
- }, {
- // Global configuration for all images
- // The output quality for JPEG, WebP and TIFF output formats
- quality: 70,
- // Use progressive (interlace) scan for JPEG and PNG output
- progressive: true,
- // Strip all metadata
- withMetadata: false,
- // Do not emit the error when image is enlarged.
- errorOnEnlargement: false,
- }))
- .pipe(gulp.dest('img/dist'));
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement