Skip to content

Instantly share code, notes, and snippets.

@lushone
Created May 9, 2013 20:17
Show Gist options
  • Save lushone/5550239 to your computer and use it in GitHub Desktop.
Save lushone/5550239 to your computer and use it in GitHub Desktop.
get an image's dimensions using pure js
/**
* get an image's dimensions using pure js
*/
var img = new Image();
img.onload = function() {
document.write('<strong>image:</strong> ' + this.src + '<br><strong>width:</strong> '+ this.width + '<br><strong>Height:</strong> ' + this.height);
}
img.src = 'http://domain.com/image.jpg';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment