I am trying to find a suitable library for image processing,
Basically, I have a use-case for Resizing, Compressing and creating thumbnails of an image,
I found that sharp seems to be a popular node library choice for image processing,
I am able to do some basic operations like resizing an image but,
I couldn't find a way to create thumbnails or smaller sized quality images of the original one.
Can someone please point to the correct code for creating thumbnails and smaller resolution images using the sharp library?
Sample working code:
const sharp = require('sharp');
let test = async () => {
await sharp('/pathToImage/test.jpg')
.resize({
fit: sharp.fit.outside
})
.sharpen()
.toFile('fitOutside.jpg')
.then(info => {
console.log(info);
})
.catch(err => {
console.log(err);
});
};
test();
Reference -
http://sharp.pixelplumbing.com/en/stable/api-resize/
https://sharp.pixelplumbing.com/en/stable/api-resize/#examples_2