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)
β Get my Node.js Handbook
I wrote 21 books to help you become a better developer:
- HTML Handbook
- Next.js Pages Router Handbook
- Alpine.js Handbook
- HTMX Handbook
- TypeScript Handbook
- React Handbook
- SQL Handbook
- Git Cheat Sheet
- Laravel Handbook
- Express Handbook
- Swift Handbook
- Go Handbook
- PHP Handbook
- Python Handbook
- Linux Commands Handbook
- C Handbook
- JavaScript Handbook
- Svelte Handbook
- CSS Handbook
- Node.js Handbook
- Vue Handbook