画像のサイズを変更する必要があるため、以下の 3 つのライブラリで、画像のサイズ変更に時間がかからないライブラリを見つける方法を説明します。
https://github.com/rsms/node-imagemagick
https://github.com/mash/node-imagemagick-native
https://github.com/aheckmann/gm
サンプルコード
var im = require('imagemagick');
var sourcePath='/tmp/Images/1.jpeg';
var destinationPath='/tmp/ResizedImages/resized.png';
im.resize({
srcPath: sourcePath,
dstPath: destinationPath,
width: 90,
height:100,
},function(err,res){
if(err){
console.log('Error while resizing image '+err);
return;
}
console.log('Image resized successfully...');
});