I have a little problem with cropping images in react native. As you can see the example below enter image description here
I want to crop the image inside the white rectangle, I don't know if I'm using the wrong formula or not
takePicture = async() => {
console.log("pic")
if (this.camera != null) {
const data = await this.camera.takePictureAsync();
/**
* Calcul
*/
const x_axis_scale = data.width / width
const y_axis_scale = data.height / height
var x_coord_int = 70 * x_axis_scale;
var y_coord_int = 120 * y_axis_scale;
var rect_width_int = 200 * x_axis_scale;
var rect_height_int = 70 * y_axis_scale
const res = await ImageEditor.cropImage(data.uri, {
offset: {x: x_coord_int, y: y_coord_int},
size: {
width:rect_width_int,
height: rect_height_int
}
})
this.setState({
imageCrop: res
})
}
};
It doesn'tt crop correcty. Any help?
Sorry , i can't help about this issue . But there is a library react-native-image-crop-picker which can help with cropping issue . Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With