WebsiteBeaver / android-document-scanner

66 stars 48 forks source link

Fix ImageCropView with long images #8

Closed PierreNicol closed 2 years ago

PierreNicol commented 2 years ago

Fix the issue https://github.com/WebsiteBeaver/react-native-document-scanner-plugin/issues/4 that happen when images have a short width and long height. In that case the bottom bar with buttons on the ImageCropView is outside the screen.

Screenshot_20221021-225139

dmarcs commented 2 years ago

@PierreNicol are you using a OnePlus phone? I'm wondering which phones cause this error. Why subtract the button height instead of the navbar height?

PierreNicol commented 2 years ago

@dmarcs Yes I use my OnePlus 6. This happens more on OnePlus because in the Photo app you can select the image ratio (4:3, 1:1 or full screen). And this issue happens with the full screen image ratio. But this option probably exist on other brands.

We have two components in our view, the image that's flexible and the bottom bar with the buttons that needs to have a minimum height and needs to be on screen. So in the case the image is very long, we calculate his height to avoid the overflow issue. And the image needs to adapt to the left space between the bottom bar with buttons and the top of the screen. So we calculate the height of the image by substracting the height of the bottom bar to the height of the screen.

dmarcs commented 2 years ago

In that case the change you made is probably correct. I'd like to see if I can set the image ratio on my Pixel to reproduce this bug.

PierreNicol commented 2 years ago

I find a way on a Pixel6A. In the system Photo app, there is a parameter to change photo format (16:9 or 4:3). And this parameter is kept when a Photo Intent is launched from another app.

Issue should happen with 16:9 photo

dmarcs commented 2 years ago

Great work @PierreNicol! I'm going to try to reproduce this, and will either use your solution or just set a fixed height on the control bar to fix the problem.

jmazier-j2d commented 2 years ago

Confirmed and reproduced via changing aspect ratio in the camera app (from 4:3 to "Full" or "9:16") with a Galaxy Tab A8 on Android 12. Also reproduced using Pixel 7. If you do change once the aspect ratio, it will stick. So, my guess is that everyone can experience this bug, but it will more likely happen with OnePlus' users as this aspect ratio is set to "Full" by default.

jmazier-j2d commented 2 years ago

Hello @dmarcs : Any update on this matter ? I've been notified that you've made a PR earlier, is that related ? Should we close this PR ?

dmarcs commented 2 years ago

Hi @jmazier-j2d I just merged this. Thanks for your help. I'll update the react native plugin.

jmazier-j2d commented 2 years ago

Hi @jmazier-j2d I just merged this. Thanks for your help. I'll update the react native plugin.

Great news ! I'll keep you posted just to confirm that the initial bug is well fixed.

shivaniCha commented 2 years ago

@jmazier-j2d @dmarcs Please help me i am using react-native-photo-editor with this scanner but when I pressed save on editor & try to save android gives scanner error although there is no use of scanner only installed Please help me