mahnunchik / gulp-responsive

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

Quality option has no effect, my images end up being larger #21

Closed hilja closed 8 years ago

hilja commented 9 years ago

My original hero image: 1600 x 672 hero.jpg, it's 1MB, after the gulp-responsive with the below task it's 1.2MB 1600 x 672 hero-1030-2x.jpg. I set the quality intentionally low but doesn't seem to have any effect on the image. The size 1030 * 2 is over the original in this case but it's not enlarged, withoutEnlargement doesn't also seem to have any effect. Is this the right way to do the configuration?

'use strict';
var gulp = require('gulp'),
    responsive = require('gulp-responsive'),
    config = require('../config.gulp').images;

gulp.task('images:resize', function() {
    return gulp.src(config.bigImgs)
        .pipe(responsive({
            // Big images with multiple sizes
            '**/*-hero.jpg': [{
                width: 600,
                rename: {suffix: '-600-1x'}
            }, {
                width: 600 * 2,
                rename: {suffix: '-600-2x'}
            }, {
                width: 786,
                rename: {suffix: '-786-1x'}
            }, {
                width: 786 * 2,
                rename: {suffix: '-786-2x'}
            }, {
                width: 1030,
                rename: {suffix: '-1030-1x'}
            }, {
                width: 1030 * 2,
                rename: {suffix: '-1030-2x'},
                quality: 40
            }],
            // Smaller images that only need retina versions
            '**/*-ret.{jpg,png}': [{
                width: '50%',
                rename: {suffix: '-1x'}
            }],
            // Really small images that only need retina versions
            '**/*-small.{jpg,png}': [{
                width: '75',
                rename: {suffix: '-75-1x'}
            }, {
                width: '150',
                rename: {suffix: '-75-2x'}
            }]
        }, {
            quality: 40,
            errorOnUnusedImage: false,
            errorOnEnlargement: false,
            withoutEnlargement: true,
            progressive: true,
            withMetadata: false
        }))
        .pipe(gulp.dest(config.dest));
});
hilja commented 9 years ago

Okay, it has effect on some of the images. But not the one that that I was looking at :) Is it because the 2x size is larger than the original and then the enlargement is skipped and so is the minification? It just seems to be this one jpg that it's not working on, weird.

mahnunchik commented 8 years ago

Hi @hilja

Could you please test it again with version 2.0 of gulp-responsive?

mahnunchik commented 8 years ago

Please reopen if necessary.