📜  如何从远程 url js 获取 img 尺寸 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:47.428000             🧑  作者: Mango

代码示例1
function getMeta(url, callback) {
    var img = new Image();
    img.src = url;
    img.onload = function() { callback(this.width, this.height); }
}
getMeta(
  "http://snook.ca/files/mootools_83_snookca.png",
  function(width, height) { alert(width + 'px ' + height + 'px') }
);