mahnunchik / gulp-responsive

gulp-responsive generates images at different sizes
https://npmjs.com/gulp-responsive
MIT License
503 stars 60 forks source link

Skip on enlargement #26

Closed mvasin closed 8 years ago

mvasin commented 8 years ago

When I set one of these parameters: withoutEnlargement / skipOnEnlargement to true (or both of them), my gulp task processes a portion of images and stops (with no special errors). It does skip files that are smaller then resize options and prints notifications about it to console, but it doesn't process ALL the images.

If I set both options to false, all images are processed with no problems. But, of course, some happen to be enlarged for no reason, I don't like that.

I do have a plumber.

Here's my code:

    gulp.task('resize-jpg', function() {
      return gulp.src('_img/**/*.jpg')
        .pipe(plumber())
        .pipe(gulpResponsive({
          '**/*.jpg': [{
            width: 2048,
            withoutEnlargement: true,
            skipOnEnlargement: true,
            progressive: true,
            quality: 70,
            rename: {
              suffix: '-2048'
            }
          }, {
            width: 1536,
            withoutEnlargement: true,
            skipOnEnlargement: true,
            progressive: true,
            quality: 70,
            rename: {
              suffix: '-1536'
            }
          }, {
            width: 1080,
            withoutEnlargement: true,
            skipOnEnlargement: true,
            progressive: true,
            quality: 70,
            rename: {
              suffix: '-1080'
            }
          }, {
            width: 750,
            withoutEnlargement: true,
            skipOnEnlargement: true,
            progressive: true,
            quality: 70,
            rename: {
              suffix: '-750'
            }
          }, {
            width: 320,
            withoutEnlargement: true,
            skipOnEnlargement: true,
            progressive: true,
            quality: 70,
            rename: {
              suffix: '-320'
            }
          }]
        }))
        .pipe(gulp.dest('dest/img'));
    });
mvasin commented 8 years ago

I put a repository to try this bug: https://github.com/mvasin/skip-on-enlarge

mahnunchik commented 8 years ago

Hi @mvasin

Sorry for the delay.

skipOnEnlargement option just removes small images from the stream. If I understand correctly, it is what happens.

A suitable combination for your task is:

withoutEnlargement: true,
skipOnEnlargement: false, // default
mahnunchik commented 8 years ago

Please reopen if necessary.