A lightweight JavaScript library to get image dimensions (width, height, type) from streams or data with minimal reads.
image-dimensions is a JavaScript library that extracts width, height, and format type from image files without loading the entire image. It solves the problem of efficiently obtaining image metadata by reading only the necessary bytes from streams or in-memory data, supporting formats like JPEG, PNG, WebP, AVIF, and HEIF.
JavaScript developers working in Node.js, browsers, Bun, or Deno who need to quickly retrieve image dimensions for processing, validation, or layout calculations without full image decoding.
Developers choose image-dimensions for its zero dependencies, cross-environment compatibility, and efficient stream-based reading that minimizes data transfer and memory usage compared to heavier alternatives like image-size.
Get the dimensions of an image
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Lightweight with no external dependencies, reducing bundle size and complexity, as emphasized in the Key Features.
Works in Node.js, browsers, Bun, and Deno without environment-specific code, ensuring broad runtime support from the README.
Uses `imageDimensionsFromStream` to read only necessary bytes from streams, minimizing data transfer for network or file handling.
Handles JPEG, PNG, GIF, WebP, AVIF, and HEIF/HEIC, covering many contemporary image formats used in web development.
Does not support all image formats; for example, JPEG XL is not included, and the README states supporting all formats is a non-goal.
Returns raw pixel dimensions without applying EXIF or HEIF/AVIF rotation, which can lead to incorrect values for oriented images, as noted in the API documentation.
Lacks some features found in libraries like `image-size`, such as broader format support and orientation handling, as acknowledged in the FAQ section.