[英]base64 image decoding intermittently reporting 1x1 dimensions
Using ie9/ie10, I am trying to detect the dimensions of a base64 image. 我正在尝试使用ie9 / ie10来检测base64图像的尺寸。 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. 片刻之后到达成功的已加载回调,但是...图片尺寸报告为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. 使用
onload
回调。 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 . 尝试使用naturalWidth而不是width 。 It works for me in Internet Explorer 10.
它适用于Internet Explorer 10。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.