Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

browser-image-size

cesarandreu20.3kMIT1.1.0

Get image size in the browser

browser, browserify, image, size, webpack

readme

Browser image size

NPM version build status

Sauce Test Status

Installation

$ npm install browser-image-size

To use browser-image-size you must polyfill Promise.

Usage

var browserImageSize = require('browser-image-size')

browserImageSize('128.png')
.then(function (size) {
  console.log(size)
  // => {height: 128, width: 128}
})

API

browserImageSize(image)

Parameters:

  • image : {(File|blob|string)} File, blob, or URL string

Returns:

  • BrowserImageSizePromise : {Promise} resolved with object containing image width and height

Tests

$ npm test -- --local

License

MIT

changelog

1.1.0 / 2014-05-08

  • Move object-url require into browserImageSize function

1.0.2 / 2015-04-14

  • Use object-url to create and revoke url

1.0.1 / 2015-04-14

  • Check url before trying to load the image

1.0.0 / 2015-04-14

  • Initial release