ionic 将 base64 字符串保存为图库中的图像
ionic save base64 string as image in galary
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的ionic应用程序点击并显示在屏幕上,如何将这个base64字符串保存为galary中的图像并获取每个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 即可开始在 galary 中保存图像。
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的ionic应用程序点击并显示在屏幕上,如何将这个base64字符串保存为galary中的图像并获取每个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 即可开始在 galary 中保存图像。