2
I am transforming an image I send by camera in Base64 but the image is all black, I do not know what is wrong, follows below my code
app.encodeImageUri(mediaFiles[i].fullPath); //Aqui envio o caminho da minha imagem da seguinte maneira 'file:/storage/emulated/0/DCIM/Camera/140014212.jpg'
encodeImageUri: function (imageUri)
{
var c=document.createElement('canvas');
var ctx=c.getContext("2d");
var img=new Image();
img.onload = function(){
c.width=this.width;
c.height=this.height;
ctx.drawImage(img, 0,0);
};
img.src=imageUri;
var dataURL = c.toDataURL("image/jpeg");
alert(dataURL);
var tb1 = '<img src=' + dataURL + '>';
document.getElementById("imgBase64").innerHTML = tb1;
return dataURL;
},
Vinicius take a look at this post http://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript
– Gabriel Rodrigues
Is there anything that isn’t working? Isn’t the return within the expected? What’s the question?
– Erlon Charles
@Erloncharles got my comment, see if you’re more cheerful now
– Vinicius Vaz
see this link: http://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript
– Ivan Ferrer