To get the width and height of an image in Node.js, we use the image-size package.
For instance, we write
const sizeOf = require("image-size");
sizeOf("images/funny-cats.png", (err, dimensions) => {
console.log(dimensions.width, dimensions.height);
});
to call the sizeOf function to read the images/funny-cats.png image.
And we get the width and height from the dimensions parameter in the callback.