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
});
}
带有相机插件img的离子应用程序点击并显示在屏幕上,如何将这个base64字符串保存为galary中的图像,并获取每个img保存的路径?任何机构能用一个简单的例子来描述吗?
答案 0 :(得分:0)
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即可开始以节奏方式保存图片。