In the Ionic Framework Docs ( cordova-plugin-camera ):
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
let base64Image = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
So, to create a base64 image:
You insert the string 'data:image/jpeg;base64,'
+ the imageData
let base64Image = 'data:image/jpeg;base64,' + imageData;
Solution:
console.log('data:image/png;base64,' + imageData);
Edit :
- You have to monitor the coding of the image:
In your case: encodingType: this.camera.EncodingType.PNG
Therefore:
data:image/png;base64,
General:
data:image/[tipo de imagen];base64,
Where:
[image type] = jpeg, png, gif ...