get the dimensions of an image with javascript

this will show the height and width of an image using javascript

Demo


var img = new Image();
img.onload = function() {
  alert(this.width + 'x' + this.height);
}
img.src = 'https://kruxor.com/images/borat.jpg';

Other Items in javascript
Page Views

This page has been viewed 60 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹