Closed pdehaan closed 6 years ago
For anybody curious (and my own future reference), I used the sharp module to do some quick image resizing and minification:
const glob = require('glob');
const sharp = require('sharp');
const headshots = glob.sync('./images/headshots/*.jpg')
.map(img => resizeImage(img, 140));
Promise.all(headshots)
.then(() => console.log(`${headshots.length} images resized`))
.catch((err) => console.error(err));
function resizeImage(src, width, height=width) {
return sharp(src)
.resize(width, height)
.toFile(src + '.jpeg');
}
But seemingly you can't set the output filename to the same as the input filename, so I had to append some lame ".jpeg" file extension and then manually rename the 6 files in Finder.
This is great. Thank you!
1.3M down to 44K. Talk about a big improvement.
This should reduce the images/headshots/*.jpg directory from ~1.3M down to ~44K.