裁剪图像并将其保存到图库

时间:2017-12-14 14:23:01

标签: ionic2

我想从图库中选择图片,裁剪图像并将裁剪后的图像保存为图库。

我使用相机本机,但我无法再将其保存到我的画廊

const options: CameraOptions = {
     quality: 100,
     sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
     destinationType: this.camera.DestinationType.DATA_URL,
     encodingType: this.camera.EncodingType.JPEG,
     mediaType: this.camera.MediaType.PICTURE,
     //allowEdit: true
   }
   this.camera.getPicture(options).then((imageData) => {
     this.base64Image = "data:image/JPEG;base64,"+imageData;
     //this.path =this.base64Image.toDataURL;
     console.log("path ",this.base64Image);
    //resolve(this.base64Image);

   }, (err) => {
       console.log("error",err)
   });

1 个答案:

答案 0 :(得分:0)

您需要使用cordova-plugin-file自行保存文件。以下是如何操作的一些说明:

https://ourcodeworld.com/articles/read/150/how-to-create-an-image-file-from-a-base64-string-on-the-device-with-cordova