title: Chrome bug related to .naturalWidth?
body: <p>It seems that the below code randomly produces <code>aImg.naturalWidth</code> either the real width of the picture or <code>0</code>. Is it a Chrome 70.0.3538.67 for Linux bug?</p>
  
  <p>If it is not a bug, how to make it work right (not to return <code>0</code>)?</p>
  
  <pre><code>function handleImageFile(files) {
    for (var i = 0; i &lt; files.length; i++) {
      var file = files[i];
      if (file.type != 'image/jpeg') continue;
  
      var img = document.createElement("img");
      img.file = file;
  
      var reader = new FileReader();
      reader.onload = (function(aImg) {
        return function(e) {
          $('#newPictureContainer').css('display', 'block');
          document.getElementById('newPicture').appendChild(img);
          aImg.src = e.target.result;
          if (aImg.naturalWidth &gt;= 300 || aImg.naturalHeight &gt;= 300) {
            if (aImg.naturalWidth &lt;= aImg.naturalHeight)
                aImg.width = 300;
            else
                aImg.height = 300;
            $('#selectPicture').css('display', 'none');
          } else {
            $('#selectPicture [type=file]').val("");
            alert("The smallest side of the picture should be at least 300 pixels.");
          }
        };
      })(img);
      reader.readAsDataURL(file);
    }
  }
  
  
    &lt;div id="selectPicture" style="display:block"&gt;
      &lt;input type="file" name="imageUpload" onchange="handleImageFile(this.files)"/&gt;
    &lt;/div&gt;
    &lt;div id="newPictureContainer" style="display:none"&gt;
      &lt;span id="newPicture"&gt;&lt;/span&gt;
      &lt;img src="/include/javascript/israelinfo/multiuploader/images/cross-small.gif"
            width="16" height="16" title="Удалить" alt="Delete" class="MUdelete"
            onclick="closePicture()"&gt;
    &lt;/div&gt;
  </code></pre>