capacitor-community / capacitor-community/camera-preview

Android - Orientation of B64 image upside down with Front Facing Camera

Open
#110 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
227
Forks
185
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When taking a photograph on the Samsung Galaxy A40 using the front facing camera on device, the finalised base64 image appears upside down, even after the supposed fix of #75. On NPM Version 2.0.0-beta0

**To Reproduce**
Load the camera preview and run `await CameraPreview.capture();` displaying the image in an img tag.

**Expected behavior**
The expected behaviour is that regardless of camera, the orientation should always be the right way up.

**Screenshots**
![Screenshot_20210314-190518](https://user-images.githubusercontent.com/49694881/111080966-f1e4ed80-84f8-11eb-80aa-bff35c044963.jpg?s=200)
![Screenshot_20210314-190539](https://user-images.githubusercontent.com/49694881/111080970-f4474780-84f8-11eb-9610-06a17eca1342.jpg?s=200)

**Smartphone (please complete the following information):**
- Device: Samsung Galaxy A40
- OS: Android 10

**Additional context**
Oddly, the device has 3 cameras available: Back, Front (Really Zoomed In, but front camera) and Front (less zoomed in, [i'm guessing Ultrawide]). To get to the front facing camera i have to call the flip function twice, which led me to believe that the `cameraCurrentlyLocked == Camera.CameraInfo.CAMERA_FACING_FRONT` part of the `if` statement on L658 was blocking reaching the `switch` statement. Once i removed that part of the `if` statement it worked as expected, however this caused the back camera to (as you probably guessed), flip upside down.

I edited CameraActivity.java#658 to `if(cameraCurrentlyLocked != Camera.CameraInfo.CAMERA_FACING_BACK && disableExifHeaderStripping) {` and now everything seems to be working, although i don't know if this would work with cameras having multiple back facing cameras, therefore will not submit a pull request until more information has come in.

I do not know Java so i don't know what is at fault here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.