0%

JS 获取图片宽高

记一下获取图片宽高的方法

1
2
3
4
5
6
7
8
9
function getMeta(url) {
var img = new Image();
img.onload = function () {
let { width, height } = img;
console.log('{width, height} :>> ', { width, height });
};
img.src = url;
}
getMeta("https://www.xxxx.com/images.png")