Remove Image from storage after getting image info

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Imre
    New Member
    • Apr 2016
    • 1

    Remove Image from storage after getting image info

    Befor uploading Images to Server I want to get the height and width of Images. To do it, I use FileReader.

    Code:
      var f = files[i];
      //Item from input files
      var oFReader = new window.FileReader();
      oFReader.readAsDataURL(f);
      oFReader.onload = function (oFrEvent) {
          var res = oFrEvent.target.result;
          var img = new Image();
          img.onload = function () {
             imgList.push({width:img.width, height:img.height})
             img = null;
          }
          img.src = res;
       }
    I tried to open over 30 Pictures, size > 3 MB.
    After ca. 20 Pictures (i=20) by
    img.src=res; i get:
    JavaScript runtime error: Not enough storage is available to complete this operation.

    How to remove img from storage?
    img = null; does not help.

    Best regards and thanks
    Last edited by Dormilich; Apr 11 '16, 07:00 AM. Reason: please use code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    never got such a error message - is that occuring in IE? seems there are a few reported issues with IE that throw this error message - seems it can occur in different situations.

    can you try another browser to confirm that? since you dont need the image anymore after loading them to check - you could even try to not create a new image object every time and read into the same object. that way you would need to 'serialize' the read tho (read again after loading each image) - which might be a bit slower - but it reads from the local machine so it shouldnt be such a big deal. if its to slow - then you can try to set up 2 image objects that can load simultanously - and increase the number until the error occurs and stick with the number that still works then.

    Comment

    Working...