Skip to content

luxp/image-file-size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image-file-size

A module for browser to get dimensions of any image file, autodetect the orientation of the image file

online demo

Usage

  • npm install --save image-file-size
import {getImageSize} from 'image-file-size'

document.getElementById('fileInput').onchange = function (event) {
  let file = event.target.files[0]
  if (file) {
    getImageSize(file)
      .then((result) => {
        document.getElementById('result').innerText = JSON.stringify(result, null, 2)
      })
  }
}

the getImageSize will return an object like {width: 100, height: 300}

LICENCE

MIT

Copyright (c) 2018-present, Xianpo (Alan) Lu

About

A module for browser to get dimensions of any image file, autodetect the orientation of the image file

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published