Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Camera plugin requires users to edit the photo first even though edit is set to disabled #2210

Closed
3 tasks
REPTILEHAUS opened this issue Nov 26, 2019 · 6 comments

Comments

@REPTILEHAUS
Copy link

Bug Report

Capacitor Version

npx cap doctor output:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 1.3.0

  @capacitor/core: 1.3.0

  @capacitor/android: 1.3.0

  @capacitor/ios: 1.3.0

Installed Dependencies:

  @capacitor/core 1.3.0

  @capacitor/cli 1.3.0

  @capacitor/android 1.3.0

  @capacitor/ios 1.3.0


[success] Android looking great! 👌
  Found 10 Capacitor plugins for ios:
    com-sarriaroman-photoviewer (1.2.4)
    cordova-plugin-actionsheet (2.3.3)
    cordova-plugin-advanced-http (2.2.0)
    cordova-plugin-dialogs (2.0.2)
    cordova-plugin-facebook4 (6.2.0)
    cordova-plugin-file (6.0.2)
    cordova-plugin-market (1.2.0)
    cordova-sqlite-storage (3.4.0)
    es6-promise-plugin (4.2.2)
    uk.co.workingedge.phonegap.plugin.launchnavigator (5.0.4)
[success] iOS looking great! 👌

Affected Platform(s)

  • [X ] Android
  • iOS
  • Electron
  • Web

Current Behavior

Expected Behavior

Sample Code or Sample Application Repo

  
    async sendImageFromCamera() {
        return this.sendImage(CameraSource.Camera)
    }

    async sendImageFromLibrary() {
        return this.sendImage( CameraSource.Photos )
    }  
  
    async sendImage(pictureSourceType: CameraSource ) {
        if (!this.capacitor) {
            if (pictureSourceType === CameraSource.Camera) {
                   let modal: HTMLIonModalElement = await this.modalCtrl.create({
                        component: CameraMsgModal,
                        componentProps: {}
                    });        
                    modal.onDidDismiss().then((imageBase64: any) => {
                        if (imageBase64) {
                            try {
                                 this.sendImageBase64(`data:image/jpeg;base64,${imageBase64.data}`) // provides a jpeg webcam shot rather than png
                            } catch (error) {
                                this.log.error
                            }
                        }
                    });
                    this.log.log('presenting modal...')
                    try {
                        await modal.present();   
                    } catch (error) {
                        this.log.error
                    }                    
            }
            return
        } else {
            const options: CameraOptions = {
                direction: CameraDirection.Rear,
                saveToGallery: false,
                presentationStyle: "fullscreen",
                allowEditing: false,
                correctOrientation: true,
                quality: 60,
                width: 400,
                height: 400,
                resultType: CameraResultType.Base64,
                source: pictureSourceType
            }        
            try {
            const image = await Camera.getPhoto(options);
            const imageUrl = image.base64String 
            if(imageUrl) {
                this.sendImageBase64(`data:image/jpeg;base64,${imageUrl}`)                           
            }
            } catch (error) {
                this.log.error(`Error encountered while user selecting image pre-crop ${error}`)
            }            
        }      
    }
    

Reproduction Steps

Android phone with ionic capacitor app, allow user 2 methods in the controller 1 for taking a new photo and 1 for taking from gallery. User selects either take photo or from gallery and it only sends if they edit the photo they just took in the photos app and add a filter and click save - expected result as was working with the cordova previously is to just select or take a photo and it will send directly to the apps interface.

Issue most prevalent on Android, IOS still asks you to edit the image before sending also but its less of a hassle and feels more native.

Other Technical Details

npm --version output:
6.9.0

node --version output:
v10.16.0

@REPTILEHAUS
Copy link
Author

Steps to reproduce (Huawei Nova)

  1. Click on camera button in app to take photo or select a photo
  2. Camera app launches and I take a picture, confirm with clicking on tick on top right
  • the next step happens but it is not desired as allowEditing is set to false
  1. "Complete action using" screen that lets me select either "View and edit" or "Photos"

@jcesarmobile
Copy link
Member

I can't reproduce on my devices, can you provide a sample app just in cases something is different from the code you shared here?

Also, would be good to know android version of the device and if only happens in that one (if you tested more)
Since the plugin just launches an Intent to the Camera app, might be possible that the Camera of that device behaves like that.

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Jan 15, 2020
@aspoonemore
Copy link

I can duplicate this as well on a SAMSUNG-SM-J327A Android 7.0 physical device as well as in the simular on a Pixel 3a running API 29.

  1. Launch camera from function below
  2. Take photo
  3. After taking photo, the edit screen is shown with no option to save. Click the x and you lose the photo. (screenshot below)
  4. Make an edit and you're able to "save copy" and the photo is sent back into the app (screenshot below)

Screenshot_20200125-102625
Screenshot_20200125-102637

async takeAPhoto() {
try {
const image = await Camera.getPhoto({
quality: 100,
allowEditing: false,
resultType: CameraResultType.Base64
});
// var imageUrl = "data:image/png;base64," + image.base64String;
var imageUrl = image.base64String;
this.image = imageUrl;

  this.openAddPhotoModal(this.image);
} catch (error) {
  console.error("error opening camera")
  console.error(error);
}

}

@aspoonemore
Copy link

Also, this looks to be the same as #2020

@jcesarmobile
Copy link
Member

closing since the reporter didn't answer.

For the "losing photo if you cancel" bug, that's fixed already.

@jcesarmobile jcesarmobile removed the needs reply needs reply from the user label Feb 19, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 12, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants