{"_id":"image-dimensions","_rev":"15-6d7c85163058f2747e8475cf03eab9c1","name":"image-dimensions","dist-tags":{"latest":"2.6.0"},"versions":{"1.0.0":{"name":"image-dimensions","version":"1.0.0","keywords":["image","dimensions","browser"],"author":{"url":"http://jongleberry.com","name":"Jonathan Ong","email":"me@jongleberry.com"},"license":"MIT","_id":"image-dimensions@1.0.0","maintainers":[{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"homepage":"https://github.com/mgmtio/image-dimensions","bugs":{"url":"https://github.com/mgmtio/image-dimensions/issues"},"dist":{"shasum":"018046697458a08ab0372231e022fcedcbc0f095","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-1.0.0.tgz","integrity":"sha512-9s7E9wG5PAFCD8mUsaMZ/CYSk2aHUMGmZk/TbQZMDGb+bSBxKzhDrZxQrtXz7rvgvp5ptZex2JEy1Nkz3SBQJA==","signatures":[{"sig":"MEQCIGjwWEaV3g7WUWZnyHIse7VOMAmGc1AAPVGcXZiMOm/7AiAZXLTd7nyCrXcr9T81TmdMUSBQ3MEbQ5UUzGRm3WnhAA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","files":["index.js"],"_shasum":"018046697458a08ab0372231e022fcedcbc0f095","gitHead":"3d277ef1f5193799d03b341b50da8a94eafc80ba","scripts":{"lint":"standardberry index.js","test":"mocha","test-ci":"npm run lint && istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot"},"_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"repository":{"url":"https://github.com/mgmtio/image-dimensions","type":"git"},"_npmVersion":"2.7.5","description":"Get the dimensions of a file input","directories":{},"_nodeVersion":"1.6.4","devDependencies":{"mocha":"2","istanbul":"0","standardberry":"*"}},"2.0.0":{"name":"image-dimensions","version":"2.0.0","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"image-dimensions@2.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"homepage":"https://github.com/sindresorhus/image-dimensions#readme","bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"bin":{"image-dimensions":"cli.js"},"dist":{"shasum":"b6e5ec29d4b0cb7aad0a67ee226d18cc513f6f50","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.0.0.tgz","fileCount":8,"integrity":"sha512-pRD4EAC1htlKwfzHdegauTHaEXdY64ICKMrY3qxdRz8zZL0VI3vM5m96Dkx5XEXlFj41Ak6NZB7y2R2nkGzZKQ==","signatures":[{"sig":"MEUCIQDPVEcKLO3YpYsRierH9ps/Hd5DoqqnnYKzxfcU/yaeewIgcIDZUv7g+fx2nFOqNTi3sPgBa3LtAWQlDBCujbuk4Xw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8410},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"15552b905cbb53ac9119fd7ea3474e96e65e8af4","scripts":{"test":"xo && ava && tsc index.d.ts"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"9.2.0","description":"Get the dimensions of a PNG or JPEG image","directories":{},"_nodeVersion":"20.9.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","typescript":"^5.2.2"},"_npmOperationalInternal":{"tmp":"tmp/image-dimensions_2.0.0_1699197813886_0.6648453507918071","host":"s3://npm-registry-packages"}},"2.1.0":{"name":"image-dimensions","version":"2.1.0","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"image-dimensions@2.1.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/image-dimensions#readme","bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"bin":{"image-dimensions":"cli.js"},"dist":{"shasum":"5bc780490a8fb0d16fc80daa4f58c2710e0cbb2f","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.1.0.tgz","fileCount":9,"integrity":"sha512-h+wbkHVhD1VAxTtedBqSwQj+AKmz90qiryKPwE9sjxheC4nWytVUsHWX0mixXY1D6pxwcE0opPJbikJRb34LoQ==","signatures":[{"sig":"MEQCIAisO9I6TJRiknGy216pHyYqFwcN1QRNkdG3Q6wHRruvAiA3bUj8Ey97jZGaEGz/dP362ofneWlU0Z5TD43EWvoBdQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9003},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"971fd1aa8b09815d2b58fe6b98d8bb6ec5977e87","scripts":{"test":"xo && ava && tsc index.d.ts"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"9.2.0","description":"Get the dimensions of an image","directories":{},"sideEffects":false,"_nodeVersion":"20.9.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","typescript":"^5.2.2"},"_npmOperationalInternal":{"tmp":"tmp/image-dimensions_2.1.0_1699265198543_0.22074715134281608","host":"s3://npm-registry-packages"}},"2.2.0":{"name":"image-dimensions","version":"2.2.0","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif","webp","avif"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"image-dimensions@2.2.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/image-dimensions#readme","bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"bin":{"image-dimensions":"cli.js"},"dist":{"shasum":"cce252e1861d2723497a436f4f15ee183436b165","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.2.0.tgz","fileCount":11,"integrity":"sha512-GYWCXrbRw28p4h8InYxfEaoavBWZAQZ7a+w53/mpK5a8UA1sCRZGmNQADdj/HndUT+ouzV0sD5+3dEBnyMqFIQ==","signatures":[{"sig":"MEQCIHiETmRfX1XERe/hFr+eZGTiuVWxbyWElXdnZFbXg+OvAiBY/dLCK+cWVfGo0vdJHCIBgUipfeWH03oqF3ouBmf2ow==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13408},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"aacf19d1a35bfd54bdd7764e2c7e1d3cf7b122b3","scripts":{"test":"xo && ava && tsc index.d.ts"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"9.2.0","description":"Get the dimensions of an image","directories":{},"sideEffects":false,"_nodeVersion":"20.9.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","typescript":"^5.2.2"},"_npmOperationalInternal":{"tmp":"tmp/image-dimensions_2.2.0_1699442327225_0.36626720010410874","host":"s3://npm-registry-packages"}},"2.3.0":{"name":"image-dimensions","version":"2.3.0","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif","webp","avif"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"image-dimensions@2.3.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/image-dimensions#readme","bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"bin":{"image-dimensions":"cli.js"},"dist":{"shasum":"ddb549de9e0825a4df2568bafae9a6dd306354d4","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.3.0.tgz","fileCount":12,"integrity":"sha512-8Ar3lsO6+/JLfnUeHnR8Jp/IyQR85Jut5t4Swy1yiXNwj/xM9h5V53v5KE/m/ZSMG4qGRopnSy37uPzKyQCv0A==","signatures":[{"sig":"MEUCIDmb0YJlJmu0yF1wfsrYpjtrzo2uRAOhYMQwF5BIWj40AiEAmRnZe0beRbg7gB/0tVGLL4wGV24NXCwNYq8bHnNTI94=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14829},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"5a103f90178f23fb2271c65bf3a3682db016692d","scripts":{"test":"xo && ava && tsc index.d.ts"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"9.2.0","description":"Get the dimensions of an image","directories":{},"sideEffects":false,"_nodeVersion":"18.19.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^6.0.1","typescript":"^5.3.3"},"_npmOperationalInternal":{"tmp":"tmp/image-dimensions_2.3.0_1703023863954_0.9079503769571724","host":"s3://npm-registry-packages"}},"2.4.0":{"name":"image-dimensions","version":"2.4.0","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif","webp","avif","heic","heif"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"image-dimensions@2.4.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/image-dimensions#readme","bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"bin":{"image-dimensions":"cli.js"},"dist":{"shasum":"ac2fe99c39b4642bd11ddee40d35667556dd92fa","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.4.0.tgz","fileCount":13,"integrity":"sha512-0SscKWh1jtXJStcsQHRLrE4Sgxd1y+g3E/28hiY1JElNfYX54MLjilwlU1AsfCmr/EdQPET4fewtbzuYNutJsQ==","signatures":[{"sig":"MEUCIQCSOfMp7p0mUPpAUxq+BR6FPzVnd+IObamZZYtAvBQX0QIgfzLD4ecggFR8CfCno+lu4ygojJPnB+kAWqCVA9IG5g0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18012},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"d4b588077b5470bab243e4264670e15ba4da9841","scripts":{"test":"xo && ava && tsc index.d.ts"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"10.9.2","description":"Get the dimensions of an image","directories":{},"sideEffects":false,"_nodeVersion":"20.19.1","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^6.0.1","typescript":"^5.3.3"},"_npmOperationalInternal":{"tmp":"tmp/image-dimensions_2.4.0_1756042488560_0.6830110005975494","host":"s3://npm-registry-packages-npm-production"}},"2.5.0":{"name":"image-dimensions","version":"2.5.0","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif","webp","avif","heic","heif"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"image-dimensions@2.5.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/image-dimensions#readme","bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"bin":{"image-dimensions":"cli.js"},"dist":{"shasum":"57476c343228fb73beccdfd2686d2633f35f382b","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.5.0.tgz","fileCount":13,"integrity":"sha512-CKZPHjAEtSg9lBV9eER0bhNn/yrY7cFEQEhkwjLhqLY+Na8lcP1pEyWsaGMGc8t2qbKWA/tuqbhFQpOKGN72Yw==","signatures":[{"sig":"MEUCIQC07LQKsin5sqYkleLjA2ZOOullvW9JUGx3aTlhJRe20QIgFOojqsNsXrihkjRGi6+j+u2MHQn5EuKXCXDcvZ+ZWc8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18689},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"aa978c8d17d96a1c73e571689b40cf046fba0a72","scripts":{"test":"xo && ava && tsc index.d.ts"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"10.9.2","description":"Get the dimensions of an image","directories":{},"sideEffects":false,"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^6.0.1","typescript":"^5.3.3"},"_npmOperationalInternal":{"tmp":"tmp/image-dimensions_2.5.0_1757334057039_0.32821833583672144","host":"s3://npm-registry-packages-npm-production"}},"2.5.1":{"name":"image-dimensions","version":"2.5.1","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif","webp","avif","heic","heif"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"image-dimensions@2.5.1","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/image-dimensions#readme","bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"bin":{"image-dimensions":"cli.js"},"dist":{"shasum":"cb9e2a959aa4a0a2938079f50e7129f6354fbf21","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.5.1.tgz","fileCount":13,"integrity":"sha512-It7CkTNp7IYA8jhvGgz8K18OAbHF3/Juk8RNEyTyMFfolJOIU1Y2wGDnzDQPbGCjyxVF/++pwIZE0BKJUEOb1g==","signatures":[{"sig":"MEUCIGFwbvqmc6TA23E9+NWk00qfQROQupYnpkEbQGKfSEG1AiEAuD/a1YVtKFMrMFT5HBP56SFMJ6XM6/HSwFsLCYrllyc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19454},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"bef83c7e528792fe5a202682f7cbbff9d5bbdf1e","scripts":{"test":"xo && ava && tsc index.d.ts"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"11.12.0","description":"Get the dimensions of an image","directories":{},"sideEffects":false,"_nodeVersion":"25.8.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^6.0.1","typescript":"^5.3.3"},"_npmOperationalInternal":{"tmp":"tmp/image-dimensions_2.5.1_1778599463258_0.20248079374302574","host":"s3://npm-registry-packages-npm-production"}},"2.6.0":{"_id":"image-dimensions@2.6.0","ava":{"timeout":"1m"},"bin":{"image-dimensions":"cli.js"},"bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"dist":{"shasum":"fa53da1e33a8877c1f6bfcb821353b4279b8297b","tarball":"https://registry.npmjs.org/image-dimensions/-/image-dimensions-2.6.0.tgz","fileCount":13,"integrity":"sha512-j1cgVnvl0ltv7tYImMYMlrkYeDB43oSUiQv3zodkImsFbJWmJZ6M5e5N9k5/8zdMVjrtYzRbmcqTqpxvyh29vw==","signatures":[{"sig":"MEQCIFKPJ9nLzmTInMLLRydqK2n6YVyINXWbKgcI8vEi3b5RAiByQPI0fS1b7fyuzK+csAgOltmGjcLMb67kQtF4gMul8g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHZ6+nRXoCqQsOeQvk9AUy8e85YE5C2jrv2jFO5CUCMaAiA873MWuekDIm3boqwvJxTTuw6vZdrZG81zcuvIA6b93A=="}],"unpackedSize":24126},"name":"image-dimensions","type":"module","types":"./index.d.ts","author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"2cc116512f20dc20cbb265aa69d6f98c7d09ce41","license":"MIT","scripts":{"test":"xo && ava && tsc index.d.ts"},"version":"2.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"homepage":"https://github.com/sindresorhus/image-dimensions#readme","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif","webp","avif","heic","heif"],"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"_npmVersion":"12.0.1","description":"Get the dimensions of an image","directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"sideEffects":false,"_nodeVersion":"22.23.1","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^6.0.1","typescript":"^5.3.3"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/image-dimensions_2.6.0_1789736030596_0.04388976589680271"}}},"time":{"created":"2015-04-14T05:36:16.051Z","modified":"2026-09-18T12:53:50.883Z","1.0.0":"2015-04-14T05:36:16.051Z","2.0.0":"2023-11-05T15:23:34.057Z","2.1.0":"2023-11-06T10:06:38.737Z","2.2.0":"2023-11-08T11:18:47.410Z","2.3.0":"2023-12-19T22:11:04.182Z","2.4.0":"2025-08-24T13:34:48.782Z","2.5.0":"2025-09-08T12:20:57.237Z","2.5.1":"2026-05-12T15:24:23.399Z","2.6.0":"2026-09-18T12:53:50.717Z"},"bugs":{"url":"https://github.com/sindresorhus/image-dimensions/issues"},"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","homepage":"https://github.com/sindresorhus/image-dimensions#readme","keywords":["image","dimensions","width","height","size","resolution","metadata","uint8array","buffer","data","bytes","binary","stream","cli","cli-app","png","jpeg","jpg","gif","webp","avif","heic","heif"],"repository":{"url":"git+https://github.com/sindresorhus/image-dimensions.git","type":"git"},"description":"Get the dimensions of an image","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"readme":"# image-dimensions\n\n> Get the dimensions of an image\n\n*Works in any modern JavaScript environment (browsers, Node.js, Bun, Deno, etc).*\n\nSupporting all kinds of image formats is a non-goal. However, pull requests for adding JPEG XL are welcome.\n\n## Supported formats\n\n- JPEG\n- PNG (and APNG)\n- GIF\n- WebP\n- AVIF\n- HEIF (including HEIC)\n\n## Install\n\n```sh\nnpm install image-dimensions\n```\n\n## Usage\n\n```js\nimport {imageDimensionsFromStream} from 'image-dimensions';\n\n// In this example, it will only read a few bytes of the image instead of fetching the whole thing.\n\nconst url = 'https://sindresorhus.com/unicorn';\n\nconst {body} = await fetch(url);\n\nconsole.log(await imageDimensionsFromStream(body));\n//=> {width: 1920, height: 1080, type: 'png'}\n```\n\n## API\n\n`ImageType` is exported and can be one of: `'png'`, `'jpeg'`, `'gif'`, `'webp'`, `'avif'`, or `'heic'`.\n\n### `imageDimensionsFromStream(stream: ReadableStream<Uint8Array>): Promise<{width: number; height: number; type: ImageType} | undefined>`\n\nGet the dimensions of an image by reading the least amount of data.\n\nPrefer this method.\n\nReturns the image dimensions and type, or `undefined` if the image format is not supported or the image data is invalid.\n\nNote: Returns raw pixel dimensions; orientation (EXIF or HEIF/AVIF `irot`) is not applied.\n\n```js\n// Node.js example\nimport {createReadStream} from 'node:fs';\nimport {Readable} from 'node:stream';\nimport {imageDimensionsFromStream} from 'image-dimensions';\n\nconst stream = Readable.toWeb(createReadStream('unicorn.png'));\n\nconsole.log(await imageDimensionsFromStream(stream));\n//=> {width: 1920, height: 1080, type: 'png'}\n```\n\n### `imageDimensionsFromData(data: Uint8Array): {width: number; height: number; type: ImageType} | undefined`\n\nGet the dimensions of an image from data.\n\nThis method can be useful if you already have the image loaded in memory.\n\nReturns the image dimensions and type, or `undefined` if the image format is not supported or the image data is invalid.\n\nNote: Returns raw pixel dimensions; orientation (EXIF or HEIF/AVIF `irot`) is not applied.\n\n```js\nimport {imageDimensionsFromData} from 'image-dimensions';\n\nconst data = getImage();\n\nconsole.log(imageDimensionsFromData(data));\n//=> {width: 1920, height: 1080, type: 'png'}\n```\n\n## CLI\n\n```sh\nnpx image-dimensions unicorn.png\n630x400\n```\n\n## FAQ\n\n### How does this differ from [`image-size`](https://github.com/image-size/image-size)?\n\n**Advantages of this package**\n\n- Zero dependencies\n- Smaller\n- Works in non-Node.js environments like the browser\n- Does not include unnecessary APIs for file reading\n\n**Advantages of `image-size`**\n\n- Supports more image formats\n- Supports getting JPEG image orientation\n\n## Related\n\n- [image-type](https://github.com/sindresorhus/image-type) - Detect the type of an image\n- [file-type](https://github.com/sindresorhus/file-type) - Detect the type of a file\n","readmeFilename":"readme.md","users":{"flumpus-dev":true}}