离子保存base64字符串作为库中的图像

问题描述 投票:0回答:1
   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保存的路径?任何机构都能用一个简单的例子来形容吗

cordova ionic2 ionic3 ionic-native
1个回答
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即可开始在库中保存图像。

© www.soinside.com 2019 - 2024. All rights reserved.