javascript - Cordova App - JPEG(Base64) Image Compression to Thumbnail Image Not working with windows 8.1 App? -


i trying compress jpeg(base64) thumbnail image 256x192. image showing blank after compression.

below code

    createwindowsthumbimage = function (name, type, data_url, callback) {     var img, canvas, context, result, dataurl;     img   = document.createelement("img");      img.src = "data:image/jpeg;base64," + data_url;     canvas        = document.createelement("canvas");     canvas.width  = 256;     canvas.height = 192;     context       = canvas.getcontext("2d");      // fill canvas white color avoid transperent behaviour of png images     context.fillstyle = "#ffffff";     context.fillrect(0, 0, 256, 192);    // draw image 256*192 dimention*/     context.drawimage(img, 0, 0, 256, 192);     dataurl = canvas.todataurl(type);      result = getfiledata(type, dataurl);      if (type === "image/jpeg") {         name   = name.substr(0, name.lastindexof(".")) + ".256x192.jpg";     } else {         name   = name.substr(0, name.lastindexof(".")) + ".256x192.png";     }         callback({name: name, type: type, data: result.file_data});          }; 


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -