Javascript Blob upload is corrupted -
so have code modifies image file , converts new image.
the new image (represented canvas.todataurl()
) working perfectly, conversion blob generating corrupted images.
var reader = new filereader(); reader.onload = function (e) { var canvas = document.createelement("canvas"); var context = canvas.getcontext("2d"); var imageobj = new image(); imageobj.src = e.target.result; imageobj.onload = function () { canvas.width = this.width; canvas.height = this.height; context.drawimage(imageobj, 0, 0); context.textalign = 'right'; context.fillstyle = "#fff"; context.font = "15pt calibri"; context.filltext(new date().tolocalestring(), this.width - 30, this.height - 30); var blb = new blob( [canvas.todataurl()], {type: 'image/jpeg', encoding: 'utf-8'}); buildingservice.addfile({file: blb, filename: guid}); category.pictures.push({offlinefoto: canvas.todataurl(), filenameondevice: guid}); }; }; reader.readasdataurl(file);
the images noticable bigger 1 started with, startsize = 858kb, converted = 2.107kb
Comments
Post a Comment