1. Before uploading by getting the file file in input space, want to get the width and height of this picture, but because the FileReader class and Image class have to load asynchronously, always can not Synchronize processing, using promise and async,await tried but not good, no effect, would like to ask how to modify this code, so that I can directly call this method to get the width and height?
function util() {
let reader = new FileReader()
reader.onload = function (e) {
let data = e.target.result
let img = new Image()
img.src = data
img.onload = function () {
console.log("width", img.width)
console.log("height", img.height)
}
}
reader.readAsDataURL(file)
}