ngOnInit(){
this.photos=[];
}
takePhotos(){
const options: CameraOptions = {
quality: 30,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
this.base64Image = 'data:image/jpeg;base64,' + imageData;
this.photos.push(this.base64Image);
this.photos.reverse();
}, (err) => {
// Handle error
});
}
离子应用程序与相机插件图像点击并显示在屏幕上,如何将此base64字符串保存为图库中的图像,并获得每个img保存的路径?任何机构都能用一个简单的例子来形容吗
const options: CameraOptions = {
quality: 30,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
saveToPhotoAlbum : true
}
只需添加此行saveToPhotoAlbum:true即可开始在库中保存图像。