
Here I showed only two functions - resize and toFile. You can any approach either callback or promise.
#NODEJS IMAGE RESIZE INSTALL#
Install the sharp library of NodeJS using the below command inside your NodeJS project. In this tutorial, we are going to use the NodeJS Sharp Library for doing the image resize activity. Once the user uploads an image to Facebook, they will automatically convert your images to various dimensions based on their optimization concept.

If you take Facebook, It is using various image sizes to give the user a better user experience.

To solve this problem, we as a web developer, we always will do the image resize activity automatically when the image is uploaded to the server. So it will be a big problem for users to load the image fully. But not all people had the same better connectivity. Today we have better internet connectivity. However, it will need 15MB bandwidth each time to show the image to the users. Say, for example, Assume if you are taking a photo from a professional camera and the file size around 15MB.

A normal camera image occupies a minimum of 2MB of memory. Due to the advanced devices, always the size of the image is also high. Everyone has a high-resolution mobile phone or professional camera. Today we have more sophisticated devices to capture the image.
