What is Image-Size?
Image-Size is a very simple light-weight image processing library that enables software developers to get dimensions of images at run time. The API supports a wide range of image formats and you can get dimensions of most of the popular file formats using the API. The API provides a synchronous and asynchronous method for working with the images. The asynchronous functions have a default concurrency limit of 100 and in order to change this limit, you can manually change concurrency. Furthermore, the asynchronous version doesn't work if the input is a Buffer and you'll have to use the asynchronous method instead.
At A Glance
An overview of Image-Size features.
- Get Image Dimensions
- Multi-size Images
- Get Dimensions using URL
- Disabling certain image types
- Disabling all file-system reads
Image-Size supports the popular Image file formats listed below.
Image-Size can be used in multiple environments like Node or browsers etc.
Getting Started with Image-Size
The recommended way to install Image-Size via NPM. Please use the following command to install it.
Install Image-Size Thief via NPM
npm install image-size --global
Get Image Dimensions
- Load Image-Size Library
- Get dimensions using sizeOf() method and pass image path as string
- Get width of image using dimensions.width and height using dimensions.height
const sizeOf = require('image-size') const dimensions = sizeOf('images/funny-cats.png') console.log(dimensions.width, dimensions.height)