Base64ToCamera抛出错误:尝试在Ionic 3项目中将图像保存到库中时无法解码图像

时间:2017-12-09 02:29:28

标签: cordova ionic-framework cordova-plugins

我正在开发具有相机预览功能的Ionic 3 Project。当我拍照时(我发出警告,显示错误和字符串)并尝试将图像保存在图库中但我收到此错误:图像无法解码。

Error message here

这里可能出现什么问题?

这是我的功能:(我使用相机预览和base64toGallery插件)



takePicture(){

    // picture options
    const pictureOpts: CameraPreviewPictureOptions = {
      width: 1280,
      height: 1280,
      quality: 85
    }

    // take a picture
    this.cameraPreview.takePicture(pictureOpts).then((imageData) => {
      this.picture = 'data:image/jpeg;base64,' + imageData;
      this.base64ToGallery.base64ToGallery(this.picture).then(
        res => this.showAlert('Saved image to gallery '),
        err => this.showAlert(err+ '  '+ this.picture)
      );
      //this.showAlert(this.picture)
      
    
    }, (err) => {
      console.log(err);
      this.picture = 'assets/img/test.jpg';
    });


  }




1 个答案:

答案 0 :(得分:0)

更改此行:

this.base64ToGallery.base64ToGallery(this.picture).then(

对此:

this.base64ToGallery.base64ToGallery(imageData).then(