How to resize image in Node js

前端 未结 3 1218
灰色年华
灰色年华 2020-12-20 08:10

I need to resize my images before I upload them to s3 (amazon). I tried this function but it\'s not working.

Here is the function that uploads the image.

My

3条回答
  •  醉话见心
    2020-12-20 08:50

    use this code.

    im.convert(['kittens.jpg', '-resize', '25x120', 'kittens-small.jpg'], 
    function(err, stdout){
      if (err) throw err;
      console.log('stdout:', stdout);
    });
    

    In place of kittens.jpg ,you can give path of image or in your case you can use fileStream and kittens-small.jpg will be name of resized image name.

提交回复
热议问题