jquery获取上传图片的宽高和地址图片的宽高

1获取地址图片宽高

var img = new Image();
img.onload = function(){
    alert(this.width);
    alert(this.height);
    this.onload = null;
};
img.src = url;

2、获取上传图片的宽高

var dom1 = document.getElementById(fileid);
var reader = new FileReader();
reader.onload = function (e) {
var data = e.target.result;
//加载图片获取图片真实宽度和高度
var image = new Image();
image.οnlοad=function(){
var width = image.width;
var height = image.height;

}
};
image.src= data;
};
reader.readAsDataURL(dom1.files[0]);


你可能感兴趣的:(jquery获取上传图片的宽高和地址图片的宽高)