mcihak
November 15, 2016, 7:37am
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.
saimon
November 15, 2016, 7:46am
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!
mcihak
November 15, 2016, 7:56am
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…
vaibsVB
November 15, 2016, 2:13pm
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 integer
‘1
’.
And what ionic-native
camera
v2 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…
mcihak
November 15, 2016, 3:14pm
5
No, this is android bug from git documentation
vaibsVB
November 16, 2016, 6:29am
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.
Is there any other option to do this so?
I am currently still having this problem on both IOS and Android. Is there any fix or work around for it? Thanks.
priyag
February 7, 2019, 10:18am
8
Yes,I am also tried its not working.Can u please help me for that issue @IonicDevScott