By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 820 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

Remove Image from storage after getting image info

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

Expand|Select|Wrap|Line Numbers
  1.   var f = files[i];
  2.   //Item from input files
  3.   var oFReader = new window.FileReader();
  4.   oFReader.readAsDataURL(f);
  5.   oFReader.onload = function (oFrEvent) {
  6.       var res = oFrEvent.target.result;
  7.       var img = new Image();
  8.       img.onload = function () {
  9.          imgList.push({width:img.width, height:img.height})
  10.          img = null;
  11.       }
  12.       img.src = res;
  13.    }
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
Apr 11 '16 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,298
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.
Apr 14 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.