@lalitkumarbaghel wrote:
I Used code from official documents but nothing happen they also not responding on this matter.https://capacitor.ionicframework.com/docs/apis/camera but they telling lie to the developer they saying The Camera API allows a user to pick a photo from their photo album or take a picture. On iOS, this uses UIImagePickerController, and on Android this API sends an intent which will be handled by the core Camera app by default.
my code
async getPicture(){ console.log("inside getpicture 1"); const image = await Camera.getPhoto({ quality: 90, allowEditing: true, resultType: CameraResultType.Base64, source:CameraSource.Camera }).then((imageData) => { console.log(imageData); let base64Image = 'data:image/jpeg;base64,' + imageData.base64String; this.userNewImage = base64Image; // this.userNewImage = this.sanitizer.bypassSecurityTrustResourceUrl(base64Image); }, (err) => { // Handle error }); } async getPicture2(){ console.log("inside getpicture 2"); const image = await Camera.getPhoto({ quality: 90, allowEditing: true, resultType: CameraResultType.Base64, source:CameraSource.Photos, }).then((imageData) => { console.log(imageData); let base64Image = 'data:image/jpeg;base64,' + imageData.base64String; this.userNewImage = base64Image; // this.userNewImage = this.sanitizer.bypassSecurityTrustResourceUrl(base64Image); }, (err) => { // Handle error }); } async openImageChooser() { if(!this.editable){ return; } const actionSheet = await this.actionSheetCtrl.create({ header: 'Choose image source', buttons: [{ text: 'Camera', icon: 'camera', cssClass : 'actionsheet-btn', handler: () => { // this.options.source=CameraSource.Camera; this.getPicture(); } }, { text: 'Gallery', icon: 'image', cssClass : 'actionsheet-btn', handler: () => { // this.options.source=CameraSource.Photos; this.getPicture2(); } }, { text: 'Cancel', role: 'destructive', handler: () => { // console.log('Share clicked'); } }] }); await actionSheet.present(); }
Posts: 1
Participants: 1