Created
December 20, 2016 11:25
-
-
Save gabrielstuff/36379dfbcc54d3851f3ff2caff9a2b68 to your computer and use it in GitHub Desktop.
Size of Image
This file contains 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 sizeOf(url, callback) { | |
var image = new Image(); | |
image.src = url; | |
image.onload = function () { | |
callback && callback(null, {width: image.width, height: image.height, ratio: image.width/image.height, img: image}) | |
} | |
image.onerror = function(){ | |
callback && callback('error') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment