Skip to content

webiya/dimensions-by-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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));

About

Get images width and height by url.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published