Gathering detailed insights and metrics for image-size
Gathering detailed insights and metrics for image-size
Gathering detailed insights and metrics for image-size
Gathering detailed insights and metrics for image-size
probe-image-size
Get image size without full download (JPG, GIF, PNG, WebP, BMP, TIFF, PSD)
fast-image-size
Simple stand alone module to just extract the image size from image file without using special image libraries.
react-image-size
Functional for getting dimensions of any image by url
image-meta
Detect image type and size using pure javascript
npm install image-size
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.8
Supply Chain
99.6
Quality
80.3
Maintenance
100
Vulnerability
100
License
TypeScript (97.95%)
JavaScript (2.05%)
Total Downloads
2,250,938,495
Last Day
557,028
Last Week
12,540,508
Last Month
54,273,981
Last Year
564,180,204
MIT License
2,137 Stars
544 Commits
214 Forks
17 Watchers
16 Branches
42 Contributors
Updated on Jul 06, 2025
Minified
Minified + Gzipped
Latest Version
2.0.2
Package Id
image-size@2.0.2
Unpacked Size
369.54 kB
Size
45.33 kB
File Count
116
NPM Version
11.2.0
Node Version
20.19.0
Published on
Apr 02, 2025
Cumulative downloads
Total Downloads
Last Day
-8.6%
557,028
Compared to previous day
Last Week
-8.2%
12,540,508
Compared to previous week
Last Month
0.9%
54,273,981
Compared to previous month
Last Year
24.7%
564,180,204
Compared to previous year
Fast, lightweight NodeJS package to get dimensions of any image file or buffer.
1npm install image-size 2# or 3yarn add image-size 4# or 5pnpm add image-size
Best for streams, network requests, or when you already have the image data in memory.
1import { imageSize } from 'image-size' 2// or 3const { imageSize } = require('image-size') 4 5const dimensions = imageSize(buffer) 6console.log(dimensions.width, dimensions.height)
Best for local files. Returns a promise.
1import { imageSizeFromFile } from 'image-size/fromFile' 2// or 3const { imageSizeFromFile } = require('image-size/fromFile') 4 5const dimensions = await imageSizeFromFile('photos/image.jpg') 6console.log(dimensions.width, dimensions.height)
Note: Reading from files has a default concurrency limit of 100
To change this limit, you can call the setConcurrency
function like this:
1import { setConcurrency } from 'image-size/fromFile' 2// or 3const { setConcurrency } = require('image-size/fromFile') 4setConcurrency(123456)
v1.x of this library had a sync API, that internally used sync file reads.
This isn't recommended because this blocks the node.js main thread, which reduces the performance, and prevents this library from being used concurrently.
However if you still need to use this package syncronously, you can read the file syncronously into a buffer, and then pass the buffer to this library.
1import { readFileSync } from 'node:fs' 2import { imageSize } from 'image-size' 3 4const buffer = readFileSync('photos/image.jpg') 5const dimensions = imageSize(buffer) 6console.log(dimensions.width, dimensions.height)
Useful for quick checks.
1npx image-size image1.jpg image2.png
If the target file/buffer is an HEIF, an ICO, or a CUR file, the width
and height
will be the ones of the largest image in the set.
An additional images
array is available and returns the dimensions of all the available images
1import { imageSizeFromFile } from 'image-size/fromFile' 2// or 3const { imageSizeFromFile } = require('image-size/fromFile') 4 5const { images } = await imageSizeFromFile('images/multi-size.ico') 6for (const dimensions of images) { 7 console.log(dimensions.width, dimensions.height) 8}
1import url from 'node:url' 2import http from 'node:http' 3import { imageSize } from 'image-size' 4 5const imgUrl = 'http://my-amazing-website.com/image.jpeg' 6const options = url.parse(imgUrl) 7 8http.get(options, function (response) { 9 const chunks = [] 10 response 11 .on('data', function (chunk) { 12 chunks.push(chunk) 13 }) 14 .on('end', function () { 15 const buffer = Buffer.concat(chunks) 16 console.log(imageSize(buffer)) 17 }) 18})
1import { disableTypes } from 'image-size' 2// or 3const { disableTypes } = require('image-size') 4 5disableTypes(['tiff', 'ico'])
If the orientation is present in the JPEG EXIF metadata, it will be returned by the function. The orientation value is a number between 1 and 8 representing a type of orientation.
1import { imageSizeFromFile } from 'image-size/fromFile' 2// or 3const { imageSizeFromFile } = require('image-size/fromFile') 4 5const { width, height, orientation } = await imageSizeFromFile('images/photo.jpeg') 6console.log(width, height, orientation)
Partial File Reading
SVG Limitations
File Access
setConcurrency()
Buffer Requirements
MIT
not a direct port, but an attempt to have something like dabble's imagesize as a node module.
7.5/10
Summary
image-size Denial of Service via Infinite Loop during Image Processing
Affected Versions
>= 2.0.0, < 2.0.2
Patched Versions
2.0.2
7.5/10
Summary
image-size Denial of Service via Infinite Loop during Image Processing
Affected Versions
>= 1.1.0, < 1.2.1
Patched Versions
1.2.1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 9
Details
Reason
4 existing vulnerabilities detected
Details
Reason
Found 4/24 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More