I need to display the image size in kilobyte and the dimension (height, width) using javascript/jquery. I came across few similar posts, but none could help me. I have two set o
All you have to do to use the two codes is to combine them in the displayPreview
function. You can create the image object that will append to the preview
and find it's size, width, and height all in the same function.
var _URL = window.URL || window.webkitURL;
function displayPreview(files) {
var file = files[0];//get file
var img = new Image();
var sizeKB = file.size / 1024;
img.onload = function() {
$('#preview').append(img);
alert("Size: " + sizeKB + "KB\nWidth: " + img.width + "\nHeight: " + img.height);
}
img.src = _URL.createObjectURL(file);
}