Hy I'm editing various images that are stored locally on my pc, I have no problems with a png images, but when I try editing jpg images I always get the following error
this.context.drawImage(this.image, 0, 0, this.imageWidth(), this.image
^
Error: Image given has not completed loading
here is my code
Caman('C://images//' + req.body['storedName'], function () {
var regulations = JSON.parse(req.body['regulations']);
this.saturation(regulations.saturation);
this.sepia(regulations.sepia);
this.vibrance(regulations.vibrance);
this.sharpen(regulations.sharpen);
this.brightness(regulations.brightness);
this.contrast(regulations.contrast);
this.exposure(regulations.exposure);
this[req.body['preset']]();
this.render(function () {
this.save('C://images//' + req.body['storedName']);
});
});
Any idea what the problem might be? Thanks.
EDIT after @ lombausch comment I changed my code, so now it looks like this,
var myimage = new Canvas.Image();
myimage.onload = function() {
Caman('C://images//' + req.body['storedName'], function () {
var regulations = JSON.parse(req.body['regulations']);
this.saturation(regulations.saturation);
this.sepia(regulations.sepia);
this.vibrance(regulations.vibrance);
this.sharpen(regulations.sharpen);
this.brightness(regulations.brightness);
this.contrast(regulations.contrast);
this.exposure(regulations.exposure);
this[req.body['preset']]();
this.render(function () {
var extension = path.extname(req.body['storedName']);
var filename = path.basename(req.body['storedName'],extension);
this.save('C://images//' + filename + '-caman' + extension);
res.json({ status:'success' });
});
});
};
myimage.onerror = function(err){
console.log(err);
res.json({status:"error", message:err});
};
myimage.src = 'C://images//' + req.body['storedName'];
the error doosn't show up anymore but nothing happens, and when I say nothing I mean nothing, not an error emssage, nor anything else,seems like the onload never get's fired.