I am resizing a given image (saved on disk) to different sizes:
var image = 'photos/pic';
var sizes = [1440, 1080, 720, 480];
for (var i = 0; i < sizes.length; i++) {
sharp(image + '.jpg')
.resize(sizes[i], sizes[i])
.toFile(image + '-' + sizes[i] + '.jpg');
}
This works as expected, but I guess there is room for improvements.
2000x2000
. What's the speed improvement from resizing 720x720
to 480x480
instead of 2000x2000
to 480x480
, if there is any? Considering I have to read the 720x720
file first and wait for the resizing to be finished.If you're working on a photoshoot and need all your photos resized into a specific format, look no further than Adobe Lightroom's bulk resize feature. This feature allows you to crop all your photos to a fixed size and output them at a certain set of pixel dimensions to create the highest image quality.
Resize multiple images by batch processing them Now you can batch process your images to resize them all. To do this, open Photoshop, then go to File > Automate > Batch. You should now see the Batch window. Choose the set that you created your action in, and then choose your action.
you can do it by using bluebird promise
const Promise = require('bluebird');
global.Promise = Promise;
var sizes = [{
path: 'large',
xy: 800
},{
path: 'medium',
xy: 300
},{
path: 'small',
xy: 100
}];
Promise.map(sizes, function(size) {
return sharp( img.buffer )
.resize( size.xy, size.xy )
.toFile( size.path );
});
src :- https://github.com/lovell/sharp/issues/154
i tried it and it is working 100%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With