2

I am trying to allow a user to upload an image onto a canvas of size 200MB, but when I choose that image, I get the aw snap error from google chrome. I thought there were no limitations on the FileReader API in terms of image size.

If I set the image.src to that large image within the code, it loads in seconds. But for some reason it keeps crashing when the user tries to load it. If anyone can help with this that would be great. Or if there are any suggestions on how to load a large image to a canvas other than this that would also be great.

Thanks

function handleImage(e){                
                    //clearAnnotations(); 
                    //annoRedraw();
                    //redraw();

                    var reader = new FileReader();
                    reader.onload = function(event){
                            image.src = event.target.result;
                            redraw();
                    }

                    imageName = e.target.files[0].name;

                    reader.readAsDataURL(e.target.files[0]); 
                    imageLoadedCheck();
            }

and handleImage function is called by this listener

imageLoader.addEventListener('change', handleImage, false);
flash
  • 265
  • 4
  • 15
  • What does your code look like? – Charlie Mar 22 '14 at 18:22
  • Charlie, just added the code – flash Mar 22 '14 at 18:25
  • 1
    These might help you: http://stackoverflow.com/questions/6217652/html5-file-api-crashes-chrome-when-using-readasdataurl-to-load-a-selected-image, http://stackoverflow.com/questions/7920039/html5-object-tag-with-base64-data-content-causes-chrome-to-crash, https://code.google.com/p/chromium/issues/detail?id=240682 – Charlie Mar 22 '14 at 18:39
  • Thanks for your help Charlie. I used the first link you gave me, and I it loads as the background of my entire page, but when I remove that last line "document.body.appendChild(img)" and make it so that it's drawn onto the canvas it doesn't draw – flash Mar 22 '14 at 21:47
  • I got it working, Thanks for the help Charlie. – flash Mar 22 '14 at 22:00
  • You're awesome @Charlie!!! – Walialu Mar 09 '17 at 08:37

0 Answers0