1

 getimage(Type){
        let options: CameraOptions;
        if (Type == 'camera') {
            options = {
                quality: 100,
                destinationType: this.camera.DestinationType.DATA_URL,
                encodingType: this.camera.EncodingType.JPEG,
                mediaType: this.camera.MediaType.PICTURE

            };
        }
        else if (Type == 'gallery') {
            options = {
                sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM,
                destinationType: this.camera.DestinationType.DATA_URL,
                encodingType: this.camera.EncodingType.JPEG,
                mediaType: this.camera.MediaType.PICTURE

            };

        }

        this.camera.getPicture(options).then((img) => {
            let base64Image = 'data:image/jpeg;base64,' + img;
                this.test(base64Image ) 
})

test(input:string)
    {
        let alert = this.alertCtrl.create({
            title: input,
            subTitle: input,
            buttons: ['OK']
        });
        alert.present();

the base64Image didn't output a base64image i compare the result of the output and the result of converting the same image enligne and the result of the output of my code is always the same with diffrent image

  • are the camera options set? if your Type is not 'gallery' or 'camera', the options are undefined. – Markus Dresch Jan 10 '19 at 09:05
  • Possible duplicate of [base 64 encode and decode a string in angular (2+)](https://stackoverflow.com/questions/41972330/base-64-encode-and-decode-a-string-in-angular-2) – Friso Jan 10 '19 at 09:07

0 Answers0