Created
July 14, 2018 04:34
-
-
Save GuoQichen/a4b7fea503dda83a2c23c3251fd8f5a6 to your computer and use it in GitHub Desktop.
jsUtils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getImageFileSize = (file) => new Promise((resolve, reject) => { | |
| const image = new Image() | |
| image.src = window.URL.createObjectURL(file) | |
| image.onerror = reject | |
| image.onload = () => { | |
| const width = image.naturalWidth | |
| const height = image.naturalHeight | |
| window.URL.revokeObjectURL(image.src) | |
| resolve({ width, height }) | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment