Optimize PNG, JPEG, GIF images with command line.
This is unstable now .
This is gruntfile.js
sample similar to grunt-contrib-imagemin
one.
module.exports = function (grunt) {
grunt.initConfig({
image: {
static: {
options: {
qualityRange: '80-100',
optimizationLevel: 3
},
files: {
'dist/img.png': 'src/img.png',
'dist/img.jpg': 'src/img.jpg',
'dist/img.gif': 'src/img.gif'
}
},
dynamic: {
files: [{
expand: true,
cwd: 'src/',
src: ['**/*.{png,jpg,gif}'],
dest: 'dist/'
}]
}
}
});
grunt.loadNpmTasks('grunt-image');
};
- ✔ https://github.com/sindresorhus/node-pngquant-bin
- https://github.com/zauni/node-pngquant-bin
- https://github.com/papandreou/node-pngquant
--quality min-max don't save below min, use less colors below max (0-100)
Execute ./node_modules/pngquant-bin/vendor/pngquant -h
to see more details.
-fix enable error recovery
-oN
Execute ./node_modules/optipng-bin/vendor/optipng -h
to see more details.
--shrink-normal Compress normal (7z)
Execute ./node_modules/node-advpng/bin/advpng -h
to see more details.
-rem chunkname (or "alla" or "allb")
-brute (use brute-force: try 148 different methods)
-reduce (do lossless color-type or bit-depth reduction)
Execute ./node_modules/pngcrush-bin/vendor/pngcrush -h
to see more details.
-optimize Optimize Huffman table (smaller file, but slow compression)
-progressive Create progressive JPEG file
Execute ./node_modules/jpegtran-bin/vendor/jpegtran -h
to see more details.
-i, --interlace Turn on interlacing.
-O, --optimize[=LEVEL] Optimize output GIFs.
--careful Write larger GIFs that avoid bugs in other programs.
Execute ./node_modules/gifsicle/vendor/gifsicle -h
to see more details.
MIT.