javascript - Images does not load properly on phonegap -
i having trouble image.onload
. doing take list of paths , want convert them base64
var img = new image(); img.setattribute('crossorigin', 'anonymous'); img.onload = function() { console.log("image done loading"); var canvas = document.createelement('canvas'), width = img.width, height = img.height; if (width > height) { if (width > maxsize) { height *= maxsize / width; width = maxsize; } } else { if (height > maxsize) { width *= maxsize / height; height = maxsize; } } canvas.width = width; canvas.height = height; canvas.getcontext('2d').drawimage(img, 0, 0, width, height); var dataurl = canvas.todataurl("image/jpg", 0.8); callback(imageobj, dataurl.replace(/^data:image\/(png|jpg);base64,/, "")); }; img.src = url;
now working fine on computer, on phone galaxy2 (android 4.1) succeed upload 10 photos , stop. checked on android 4.4, working excepted.
i added images html see if images loading, , half of images load properly. it's onload event stop firing.
any suggestions?
finaly solve problem, tried load way more 100 images simultaneously.
what hapend on new phones more ram app works because has enough space save images, on other hand on old phone when ram ran out error fired because couldn't load image
so changed code load 1 image @ same time
Comments
Post a Comment