181
rated 0 times
[
184]
[
3]
/ answers: 1 / hits: 5373
/ 10 Years ago, tue, june 10, 2014, 12:00:00
i am resizing an image using canvas and javascript... After the image has finished, I want to do some logic. Is there an event for finished? I tried onloadend but it never gets called:
var fr = new FileReader();
fr.onload = function (e) {
var img = new Image();
img.onloadend = function() {
console.log('finished logic here');
}
img.onload = function(){
var MAXWidthHeight = 488;
var ratio = MAXWidthHeight / Math.max(this.width,this.height);
var w = this.width * ratio;
var h = this.height * ratio;
var c = document.createElement(canvas);
c.width = w;
c.height = h;
c.getContext(2d).drawImage(this,0,0,w,h);
this.src = c.toDataURL();
document.body.appendChild(this);
}
img.src = e.target.result;
}
fr.readAsDataURL(files[i]);
More From » canvas