Copyright 2025

The Valley of Code

A Flavio Copes project

How to get an image width and height using Node
How to get an image width and height using Node

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)

Join my AI Workshop !

The Web Development BOOTCAMP cohort starts in February 2026