我正在开发具有相机预览功能的Ionic 3 Project。当我拍照时(我发出警告,显示错误和字符串)并尝试将图像保存在图库中但我收到此错误:图像无法解码。
这里可能出现什么问题?
这是我的功能:(我使用相机预览和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';
});
}

答案 0 :(得分:0)
更改此行:
this.base64ToGallery.base64ToGallery(this.picture).then(
对此:
this.base64ToGallery.base64ToGallery(imageData).then(