0.1.0 • Published 3 years ago
dimensions-by-url v0.1.0
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));
0.1.0
3 years ago