let img = new Image();
img.src = '图片的链接';
img.onload = async () => {
console.log(img.width)
console.log(img.height)
};`
참고: 비동기가 아닌 경우 온로드해야 값을 얻을 수 있습니다.
패키지:
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);
};
});
}
옮기다:
getVideo(url).then((res) => {
console.log(res);
});