title: Crop image using a bounding box react-native-camera
body: <p>i have a camera view in my app in which there is a resizable bounding box
  <a href="https://i.stack.imgur.com/TLJZq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TLJZq.jpg" alt="camera view bounding box image" /></a></p>
  <p>now after taking the image i want to able to only take the part of the image that was focused so i used ImageEditor from <a href="https://www.npmjs.com/package/@react-native-community/image-editor" rel="nofollow noreferrer">this react-native library</a></p>
  <p>the issue i have i am not getting consistent results on the cropping i currently have th following values
  <code>boxX</code> staring X position of the bounding box; <code>boxY</code> staring Y position of the bounding box; <code>boxWidth</code> width of the bounding box; <code>boxHeight</code> height of the bounding box.</p>
  <p>i used the following code at first</p>
  <pre><code>ImageEditor.cropImage(image.uri, 
                  {
                      offset: {x: boxX, y: boxY},
                      size: {width: boxWidth, height: boxHeight},
                  }
              )
  </code></pre>
  <p>this gives a very pixalated and very wrong cropping of the image i dont know why, then i added some calculations to it by adding new variables like the image width and height and also the devices width and height and came up with this code:</p>
  <pre><code>ImageEditor.cropImage(data.uri, 
                  {
                      offset: {x: ((boxX)/deviceWidth)*data.width, y:((boxY)/deviceHeight)*data.height},
                      size: {width: boxWidth/deviceWidth*imageWidth, height: boxHeight/deviceHeight*imageHeight},
  
                  }
              )
  </code></pre>
  <p>this is much better but the cropping is still wrong on Android but on iOS this seems to work fine and accurate, my question is how can i achieve this please let me know if there is any calculations i should do to get consistent results.</p>