Resize Images

Resize image using sharp module of node.js

30 Days of Node | Node.js Tutorial series


In this article we will learn how we can resize an image in node.js using sharp package.


We can install the sharp package using the following command:

>npm install sharp												

Please Note that sharp package works only on 64-bit architecture systems.

Image Resizing

Suppose we want to resize yellow.png which is in the same directory as our code. We can perform it in the following way :

//Name of the File : image-resize-sharp.js
const sharp = require('sharp');
const fs = require('fs');

    .then( data => {
        fs.writeFileSync('yellow.png', data);
    .catch( err => {


We can run the code using the following command:

>node image-resize-sharp.js											


We have learned how we can resize an image in node.js using sharp.