1

I need to get image name as well as base64 image when user select an image from photo library.I am using cordova Camera plugin to get image from gallery,but i am not getting image name and base64 image at the same time.

// to get base64 image
    Camera.getPicture({
        destinationType: Camera.DestinationType.DATA_URL,
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        targetWidth: 1000,
        targetHeight: 1000
    }).then((imageData) => {
      // imageData is a base64 encoded string
        this.base64Image = "data:image/jpeg;base64," + imageData;

        alert("this.base64Image="+this.base64Image);
    }, (err) => {
        console.log(err);
    });
//to get image URL
    Camera.getPicture({
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        targetWidth: 1000,
        targetHeight: 1000
    }).then((imagePath) => {
      // imageData is a base64 encoded string
        this.imagePath = imagePath;

        alert("this.imagePath="+this.imagePath);
    }, (err) => {
        console.log(err);
    });

How can i combine both of these call in single click?

Wasiq Muhammad
  • 3,080
  • 3
  • 16
  • 29
RAHUL DEEP
  • 695
  • 3
  • 13
  • 33

1 Answers1

1

Documentation says Camera.DestinationType : enum, can be used one at a time as FILE_URI or DATA_URL or NATIVE_URI

But if you want both base64 and file path, you can convert image to base64 in angularjs

Community
  • 1
  • 1
Absar Hasan
  • 184
  • 2
  • 13