Using ie9/ie10, I am trying to detect the dimensions of a base64 image. My code works in the other current browsers. These are the steps I follow:
Moments later arrives a successful loaded callback, but... the image dimensions are reported as 1x1. Sometimes. Other times it works just fine.
So... how do I detect when the image is... decoded? Not sure what is going on here.
Use onload
callback. Your image is not downloaded yet when you first try to get its size. That is why you get wrong size.
image.onload = function () {
console.log(this.width);
}
Try to use naturalWidth instead of width . It works for me in Internet Explorer 10.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.