Streamline advpng usage in your gulp build

2018-12-29 (Updated: )

See also Streamline advzip usage in your gulp build.

A quick tip: if you use advpng in your build pipeline, note that you can now pass the iterations (--iter) option through the imagemin-advpng plugin. If you haven’t used it before, it looks something like this:

gulpfile.js
1
2
3
4
5
6
7
8
const imagemin = require('imagemin');
const advpng = require('imagemin-advpng');

gulp.task('mytask', () => {
return gulp.src(['assets/*.png'])
.pipe(imagemin({ use: advpng({ optimizationLevel: 4 }) }))
.pipe(gulp.dest('out'));
});

Using the latest version of imagemin-advpng, you can now specify iterations as well; ideal for that last-pass squeeze-everything-we-possibly-can build of your js13k project:

1
2
3
return gulp.src(['assets/*.png'])
.pipe(imagemin({ use: advpng({ optimizationLevel: 4, iterations: 5000 }) }))
.pipe(gulp.dest('out'));