Get image dimension Using HTML5 with javascript, Its useful for image validation.

Html Code:

[php toolbar=”false” classname=”one_line”] <!–Input file type –>
<input type="file" id="file" />
[/php]

Javascript Code:

[php toolbar=”true” classname=”one_line”]

var _URL = window.URL || window.webkitURL;

$("#file").change(function(e) {

var image, file;

if ((file = this.files[0])) {

image = new Image();

image.onload = function() {

alert("The image width is " +this.width + " and image height is " + this.height);
};

image.src = _URL.createObjectURL(file);

}

});
[/php]

Leave A Comment