-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offset not correct in some Android devices #152
Comments
@duongdinh98 Could you provide video/image demo of what you see on Huawei P20 (I don't have such device for testing) |
Hi @retyui I'm using "@react-native-community/image-editor": "^4.2.0", In Galaxy Note 10+ and iPhone with this code above, it cropped square image perfectly like in camera preview screen, but on Huawei P20, it looks like crop without offset in the demo I shared |
@duongdinh98 how do you create |
Here is what I did import { Image as RNImage } from 'react-native';
export const getImageSize = (
uri: string,
): Promise<{ width: number; height: number }> => {
return new Promise((resolve, reject) => {
RNImage.getSize(
uri,
(imgWidth, imgHeight) => {
resolve({ width: imgWidth, height: imgHeight });
},
reject,
);
});
};
// camera obj from react-native-vision-camera
const photo = await camera.current.takePhoto(takePhotoOptions);
photo.path = `file://${photo.path}`;
const imgSize = await getImageSize(photo.path); |
can you try to swap w & h |
Not work @retyui t |
@duongdinh98 also, can you omit displaySize: {
width: imgSize.width,
height: imgSize.width,
}, |
Not work, I tried this before |
@duongdinh98 Could you please log the next variables (from const photo = await camera.current.takePhoto(takePhotoOptions);
// ^^^ - `photo` takePhoto result
const imgSize = await getImageSize(photo.path);
//. ^^^ `imgSize` - image size |
I found issue, my getImageSize() function not correctly work in some Android devices, so it will return incorrect image size => cause crop incorrectly To resolve, I swith to get image size from photo object return by react-native-vision-camera const photo = await camera.current.takePhoto(takePhotoOptions); |
Environment
Android (Galaxy Note 10+ is OK but Huawei P20 not correctly cropped)
Description
Offset not correct in some Android devices
Reproducible Demo
The text was updated successfully, but these errors were encountered: