Created
August 16, 2018 15:55
-
-
Save jnsprnw/fca6b5933de5cf3f1a7bb7704b7b983d to your computer and use it in GitHub Desktop.
Node script to minimize JPGs and convert to WebPs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const imagemin = require('imagemin'); | |
const imageminWebp = require('imagemin-webp'); | |
const imageminZopfli = require('imagemin-zopfli'); | |
const imageminMozjpeg = require('imagemin-mozjpeg'); | |
imagemin(['source/*.jpg'], 'output', { | |
progressive: true, | |
use: [ | |
imageminZopfli({ | |
more: true, | |
iterations: 50 | |
}), | |
imageminMozjpeg({ | |
quality: 70 | |
}) | |
] | |
}).then(() => { | |
console.log('JPGs optimized'); | |
}); | |
imagemin(['source/*.jpg'], 'output', { | |
use: [ | |
imageminWebp({ | |
quality: 70 | |
}) | |
] | |
}).then(() => { | |
console.log('Webp created'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment