Skip to content

Instantly share code, notes, and snippets.

@gabrielstuff
Created December 20, 2016 11:25
Show Gist options
  • Save gabrielstuff/36379dfbcc54d3851f3ff2caff9a2b68 to your computer and use it in GitHub Desktop.
Save gabrielstuff/36379dfbcc54d3851f3ff2caff9a2b68 to your computer and use it in GitHub Desktop.
Size of Image
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