How to crop an image in React Native

I use the camera with the reaction to take pictures. The photos taken are 16/9, but I need them in 4/3.

Thus, I want to crop the image, for example 1920*1440.

I am using ImageEditor from React Native. The code ImageEditorcan be found here .

My code is as follows:

this.camera.capture(target)
     .then((data) => {
           let cropData = {
               offset:{x:0,y:0},
               size:{width:1920, height:1440}
           };

           ImageEditor.cropImage(
                 data.path,
                 cropData, 
                 (uri) => {
                       this.props.captured(this.props.request, {
                             path: uri,
                             data: data.data,
                             longitude: position.coords.longitude,
                             latitude: position.coords.latitude
                             }
                       );
                       Actions.pop();
                 },
                 (error) => {});
            })
     .catch(err => {
           console.error(err)
     });

But the code above does not work. The saved photo is not cropped and composes 1440*2560.

Any advice?

+4
source share
1 answer

, captured(), , , data this.props.captured. :

, ImageStore, URI, success .

data uri

0

Source: https://habr.com/ru/post/1678269/


All Articles