Reputation: 51
In my page, I have a module in which I upload images and then I display them in 2 places.
Recently I got a work to show only the low-resolution image in one place and the same uploaded image in another place. For that, I have to store 2 images, one for high resolution (The actual image uploaded) and another with low resolution (Converted image). I am using Node.js.
Can anyone please suggest me help to convert the image into low resolution?
Upvotes: 0
Views: 2557
Reputation: 13634
ImageMagick is quite hard to work with and complicated installation.
I definitely suggest to use: https://github.com/lovell/sharp as it is 'plug and play' solution and it is really nice documented.
Upvotes: 0
Reputation: 111268
If you want to resize the images on the backend, you can use:
From the docs:
var im = require('imagemagick');
im.resize({
srcPath: 'kittens.jpg',
dstPath: 'kittens-small.jpg',
width: 256
}, function(err, stdout, stderr){
if (err) throw err;
console.log('resized kittens.jpg to fit within 256x256px');
});
If you want to resize on the frontend, you can use Canvas, see:
Upvotes: 1