Last active
January 16, 2018 05:54
-
-
Save jasonmit/582477e06a05a8e43a0c9f426588a5a5 to your computer and use it in GitHub Desktop.
promise image size
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
| function imageSize(blobString) { | |
| return new Promise((resolve, reject) => { | |
| let img = new Image(); | |
| img.onload = (err) => resolve({ width: img.naturalWidth, height: img.naturalHeight }); | |
| img.onerror = (err) => reject(err); | |
| img.src = blobString; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment