js读取图片,获取并获取图片高度和宽度

来源:互联网 发布:济南行知小学作文 编辑:程序博客网 时间:2024/05/21 10:21
if (window.FileReader) {    var image = new Image();    var reader = new FileReader();    reader.readAsDataURL(file);    //文件读取结束时间    reader.onload = function (e) {        image.src = reader.result;    };    //图片读取事件    image.onload = function () {        var height=image.naturalHeight;        var width=image.naturalWidth;    }}