Is there a way to resize a collection of images and write them to a new location using node gm
For example, say I have a folder called 'original' with 10 images in it - image-1.jpg, image-2.jpg - and I want to resize all of these into a 'resized' folder (whilst maintaining the filename). How could this be done?
This code works for a single image...
var fs = require('fs');
var gm = require('gm');
// resize and remove EXIF profile data
gm('original/image-1.jpg')
.noProfile()
.resize('1400>') // resize long edge to 1400
.write('resized/image-1.jpg', function (err) {
if (!err) console.log('done');
else console.log(err);
});
Thanks!