I'm going to find the best solution for jpg optimizing process, based on Gulp plugins (such as imagemin package). My goal is to compress jpg file like Save For Web in Adobe Photoshop - progressive: true and quality: 61.
I have one image, saved in several ways:
- 01.jpg (Photoshop -> ctrl+s, best quality(12), format: basic (standard)) - 89.5 KB
- 02.jpg (Photoshop -> ctrl+s, high quality(8), format: basic (optimized)) - 51.1 KB
- 03.jpg (Photoshop -> ctrl+s, medium quality(6), format: progressive) - 47.5 KB
- 04.jpg (Photoshop -> Save For Web, high quality(61), format: progressive) - 29.6 KB
So, my goal is to compress jpg via Gulp like 04.jpg.
The original image is 01.jpg (89.5 KB).
Results of imagemin-jpegtran and imagemin-jpegoptim aren't good enough, cause optimization level is far from Photoshop's Save For Web:
imagemin (jpegtran inside) -> 51.7 KB
imagemin-jpegoptim - couldn't to set up (any help?)
module.exports = function (gulp, plugins, config) {
var jpegoptim = require('imagemin-jpegoptim');
return function(){
gulp.src(config.assets.images.temp + '**/*.jpg')
.pipe(jpegoptim({
progressive: true
})())
.pipe(gulp.dest(config.assets.images.src));
}
};
Error: write EOF
module.exports = function (gulp, plugins, config) {
var jpegoptim = require('imagemin-jpegoptim');
return function(){
gulp.src(config.assets.images.temp + '**/*.jpg')
.pipe(plugins.imagemin({
progressive: true,
use: [
jpegoptim({
max: 61
})()
]
}))
.pipe(gulp.dest(config.assets.images.src));
}
};
Brokes image (100% of minifying - broken file)
I tryed to work with imagemin-jpeg-recompress, but it throws an error:
Error: Premature end of JPEG file
JPEG datastream contains no image
So my question is...
How to achieve the same results via Gulp, as through Photoshop Save For Web?