teslamotors / react-native-camera-kit

A high performance, easy to use, rock solid camera library for React Native apps.
MIT License
2.49k stars 590 forks source link

Ignoring user orientation settings #624

Open Zigulich opened 1 year ago

Zigulich commented 1 year ago

Describe the bug I had several problems with the user orientation being blocked when capturing a photo. Even changing the android:screenOrientation property or locking the rotation with third-party plugins, I realized that the code itself had a function to "Rotate the image according to device orientation, even when UI orientation is locked"

To Reproduce Steps to reproduce the behavior:

  1. Call cameraRef.current.capture() with the cell phone in landscape mode
  2. Even if the orientation is locked, the capture is done in landscape mode

Expected behavior The image orientation must be defined by the user, and not forced. The best option would be to add a property to the capture function, determining whether or not the orientation should be locked.

Screenshots image Locate at /node_modules/react-native-camera-kit/android/src/main/java/com/rncamerakit/CKCamera.kt:161

DavidBertet commented 11 months ago

It is the expected behavior.

It is recommended to lock the UI orientation in portrait mode while capturing for UX purposes. However the resulting image takes into account the device orientation. If the user rotated their phone while taking the picture, it takes a landscape image as expected by the user (same as the native camera app).

Could you explain why you aren't expecting this behavior in your case?

Zigulich commented 11 months ago

My case is specific, where images must only be sent in portrait mode.

Both react-native-camera and its successor react-native-vision-camera allow the configuration of orientation at the time of capture, as the developer must have control of the expected return, and in specific cases like mine, it can easily get stuck rotation, whether in portrait mode or landscape mode.

In my case, I forked the repository and removed this part of the code in my app, but it would be interesting if the app allowed configuration more easily.