dimensions-by-url

0.1.0 • Public • Published

dimensions-by-url

A simple helper to get width and height of an image by a url.

Installation

npm install dimensions-by-url

or

yarn add dimensions-by-url

Usage Example

import getImageDimensions from 'dimensions-by-url';

const url = 'https://pngimg.com/uploads/killer_whale/killer_whale_PNG15.png';

// Async-Await
try {
  const { width, height } = await getImageDimensions(url);
  console.log('width: ', width);
  console.log('height: ', height);
} catch (error) {
  console.log(error);
}

// Promise .then
getImageDimensions(url)
  .then(({ width, height }) => {
    console.log('width: ', width);
    console.log('height: ', height);
  })
  .catch(error => console.log(error));

Package Sidebar

Install

npm i dimensions-by-url

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

2.69 kB

Total Files

4

Last publish

Collaborators

  • or-yam