# How to get an image width and height using Node

> Learn how to get an image width and height in Node.js using the image-size npm module and its sizeOf() function, which reads the file from its location.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-03-09 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/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](https://flaviocopes.com/npm/) module

```javascript
npm install image-size
```

and you can use it like this:

```javascript
import sizeOf from 'image-size'

const { height, width } = sizeOf(fileLocation)
```
