@ReactMethod public void cropImage(String uri,ReadableMap options,final Callback success,final Callback error){
  ReadableMap offset=options.hasKey("offset") ? options.getMap("offset") : null;
  ReadableMap size=options.hasKey("size") ? options.getMap("size") : null;
  if (offset == null || size == null || !offset.hasKey("x") || !offset.hasKey("y") || !size.hasKey("width") || !size.hasKey("height")) {
    throw new JSApplicationIllegalArgumentException("Please specify offset and size");
  }
  if (uri == null || uri.isEmpty()) {
    throw new JSApplicationIllegalArgumentException("Please specify a URI");
  }
  CropTask cropTask=new CropTask(getReactApplicationContext(),uri,(int)offset.getDouble("x"),(int)offset.getDouble("y"),(int)size.getDouble("width"),(int)size.getDouble("height"),success,error);
  if (options.hasKey("displaySize")) {
    ReadableMap targetSize=options.getMap("displaySize");
    cropTask.setTargetSize(targetSize.getInt("width"),targetSize.getInt("height"));
  }
  cropTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

@ ReactMethod public void cropImage ( String uri , ReadableMap options , final Callback success , final Callback error ) { ReadableMap offset = options . hasKey ( "offset" ) ? options . getMap ( "offset" ) : null ; ReadableMap size = options . hasKey ( "size" ) ? options . getMap ( "size" ) : null ; if ( offset == null || size == null || ! offset . hasKey ( "x" ) || ! offset . hasKey ( "y" ) || ! size . hasKey ( "width" ) || ! size . hasKey ( "height" ) ) { throw new JSApplicationIllegalArgumentException ( "Please specify offset and size" ) ; } if ( uri == null || uri . isEmpty ( ) ) { throw new JSApplicationIllegalArgumentException ( "Please specify a URI" ) ; } CropTask cropTask = new CropTask ( getReactApplicationContext ( ) , uri , ( int ) offset . getDouble ( "x" ) , ( int ) offset . getDouble ( "y" ) , ( int ) size . getDouble ( "width" ) , ( int ) size . getDouble ( "height" ) , success , error ) ; if ( options . hasKey ( "displaySize" ) ) { ReadableMap targetSize = options . getMap ( "displaySize" ) ; cropTask . setTargetSize ( targetSize . getInt ( "width" ) , targetSize . getInt ( "height" ) ) ; } cropTask . executeOnExecutor ( AsyncTask . THREAD_POOL_EXECUTOR ) ; }
crop an image . if all goes well , the success callback will be called with the file : / / uri of the new image as the only argument . this is a temporary file - consider using camerarollmanager . saveimagewithtag to save it in the gallery .
