V
V
Vasily Vyaznikov2016-10-13 11:29:25
gulp.js
Vasily Vyaznikov, 2016-10-13 11:29:25

Why is imagemin-pngquant not giving a result?

Good afternoon!
I use gulp-imagemin to compress images. As everywhere it is recommended, I put imagemin-pngquant in addition to it. But this image did not shrink better. I don't understand what's the matter.
Connecting libraries:

var gulp = require('gulp'), //подключаем gulp
    ...
    imagemin = require('gulp-imagemin'), // Подключаем библиотеку для работы с изображениями
    pngquant = require('imagemin-pngquant'); // Подключаем библиотеку для работы с png

Tax:
gulp.task('imgmin', function() {
    return gulp.src('src/img/**/*')
        .pipe(imagemin({
            interlaced: true,
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()]
        }))
        .pipe(gulp.dest('dist/img')); 
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Smirnov, 2016-10-23
@vyaznikov1991

Better late than never))
Use the imagemin([plugins], [options]) construct, and specify the options specifically for each plugin.
For example:

gulp.task('images', function() {
    return gulp.src(src.images)
        .pipe(imageMin([
            pngquant(),
            mozjpeg({
                 progressive: true
            })
        ],{
            verbose: true
        }))
        .pipe(gulp.dest(outputDir + 'img'))
        .pipe(connect.reload())
});

Tyts

S
sergey, 2016-10-13
@zorro76

Here is an example:

var gulp = require('gulp'),
    imageMin = require('gulp-imagemin'),
    pngquant = require('imagemin-pngquant');

gulp.task('images', function() {
    return gulp.src(src.images)
        .pipe(imageMin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()],
            interlaced: true
        }))
        .pipe(gulp.dest(outputDir + 'img'))
        .pipe(connect.reload())
});

result:
[11:32:31] Using gulpfile ~/Dropbox/Projects/Work2016/mars/gulpfile.js
[11:32:31] Starting 'images'...
[11:32:54] gulp-imagemin: Minified 89 images (saved 3.85 MB - 37.4%)
[11:32:54] Finished 'images' after 23 s

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question