ImageManipulator crop requires bounds not working as expected

Hello,

Samsung S8 → take photo → returns uri + width and height. With ImageManipulator crop with 0,0 and width and height from camera both minus a small arbitrary of pixels → error crop rect not in picture when it should definitely be in the picture / valid.

With a little trial and error, if I divide width and height returned by the camera by 2 → works fine and I get basically the full image minus that little bit. If I divide by 2 and add a couple pixels → rectangle not in picture as expected. So it seems its a factor of 2 out for some reason.

I then came across this bug with resizing:

So maybe something to do with screen resolutions / pixel ratio.

Which is the bit that is really confusing me, PixelRatio.get() → returns 3.5 for my S8… not 2… So it seems somewhat unrelated to different resolutions / I cant work around it with pixel ratio.

I dont know where 2 comes from / what is safe to use / how to work around this. I need to use the camera and with an overlay help the user take a picture → crop out sections of it accurately.

Any help or insight would be great thanks.

1 Like

I’m facing exactly the same problem, I’m really confused.

https://github.com/expo/expo/issues/1406 We’ve recently raised a bug / found something causing issues.

The android lib they use is adjusting images to fit the screen whilst leaving the crop bounds alone -> breaking. If you resize the image first it seems to then have that image loaded / you can crop as expected.

1 Like

i have resized the image then cropped it, and it working for me thanks.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.