Camera options not work


#1

Hi all,
I am trying to take a photo from front camera but function for it ignores this options (width and height too). Only options that work is “saveToPhotoAlbum”. Can you please tell me what is wrong with my function?

takePhoto() {
    let options = {
        targetWidth: 380,
        targetHeight: 380,
        saveToPhotoAlbum: true,
        cameraDirection: 0
    };
    Camera.getPicture(options).then((imageData) => {
        // imageData is either a base64 encoded string or a file URI
        // If it's base64:
        let base64Image = 'data:image/jpeg;base64,' + imageData;
        console.log(base64Image);
    }, (err) => {
        // Handle error
    });
}

Thanks a lot.


#2

If you put in 0 you want to use the back camera, a 1 would stand for the front camera. See the documentation for Cordova Image Plugin here!


#3

ah. Ok, tried but not working. But it is bug on android:
Android Quirks
Any cameraDirection value results in a back-facing photo.

So this is ok, but targetWidth and Height still not work…


#4

@mcihak Have you found solution? Is cameraDirection works on your device?

@saimon I need little help.

https://github.com/apache/cordova-plugin-camera#cameradirection--enum this GitHub cordova-plugin-camera docs says in order to open FRONT camera use integer1’.

And what ionic-native camerav2 docs https://ionicframework.com/docs/v2/native/camera/#CameraOptions
says is for FRONT camera use integer '0' (camera.d.ts file says the same).

I’m confused, I tried both options cameraDirection: 0 and cameraDirection: 1.
And while running on android MOTO G4 device it opens back camera.

I also tried this one… cameraDirection: Camera.Direction.FRONT. But it opens back camera.

Can you help me out of this?

Thanks in advance…


#5

No, this is android bug from git documentation


#6

Yes right, @mcihak.

I went through documentation, at this link https://github.com/apache/cordova-plugin-camera#android-quirks-1 the first line says the all. :frowning:

Is there any other option to do this so?


#7

I am currently still having this problem on both IOS and Android. Is there any fix or work around for it? Thanks.