let img = new Image();
img.src = '图片的链接';
img.onload = async () => {
console.log(img.width)
console.log(img.height)
};`
Note: Be sure to onload, if it is not asynchronous, the value cannot be obtained
Package:
async function getVideo(fileUrl: any) {
return new Promise((resolve) => {
let img = new Image();
img.src = fileUrl;
img.onload = async () => {
let type = img.width / img.height > 1 ? "video-w" : "video-h";
resolve(type);
};
});
}
transfer:
getVideo(url).then((res) => {
console.log(res);
});