项目作者: luxp

项目描述 :
A module for browser to get dimensions of any image file, autodetect the orientation of the image file
高级语言: JavaScript
项目地址: git://github.com/luxp/image-file-size.git
创建时间: 2018-05-06T08:34:14Z
项目社区:https://github.com/luxp/image-file-size

开源协议:

下载


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
  1. import {getImageSize} from 'image-file-size'
  2. document.getElementById('fileInput').onchange = function (event) {
  3. let file = event.target.files[0]
  4. if (file) {
  5. getImageSize(file)
  6. .then((result) => {
  7. document.getElementById('result').innerText = JSON.stringify(result, null, 2)
  8. })
  9. }
  10. }

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

LICENCE

MIT

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