Skip to content

How to get an image width and height using Node

New Courses Coming Soon

Join the waiting lists

You need to know the location on file system of the image.

If it’s an image from the Internet you can save it to the system tmp folder.

Then install the image-size npm module

npm install image-size

and you can use it like this:

import sizeOf from 'image-size'

const { height, width } = sizeOf(fileLocation)
→ Get my Node.js Handbook
→ Read my Node.js Tutorial on The Valley of Code

Here is how can I help you: