I found a solution for this (it is too late, but used for someone like me), but after taking the image you need to pass the image path to the plugin (native android) for embroidery.
put the following code in your image capture or select an image from the gallery (in your index.html):
navigator.camera.getPicture(function(imageURI){ window.resolveLocalFileSystemURI(imageURI, function(fileEntry){ fileEntry.file(function(fileObj) { var imagedata ="sample/new001.img";
after that crop.image.js should look like (specify this file name in your index.html)
var cropImage = { createEvent: function(fileName) { cordova.exec( null, // success callback function null, // error callback function 'CropImage', // mapped to our native Java class called "CropImage" 'GetImageName', // with this action name [fileName] ); } }
Your java code is like
public class CropImage extends CordovaPlugin{ public final String ACTION_GET_IMAGE_NAME = "GetImageName"; Uri myUri; @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { // Log.e(TAG,"Inside Version plugin."); boolean result = false; if(action.equals(ACTION_GET_IMAGE_NAME)) { try { myUri = Uri.parse(args.getString(0)); cropCapturedImage(myUri); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } result = true; } return result; } public void cropCapturedImage(Uri picUri){ //call the standard crop action intent Intent cropIntent = new Intent("com.android.camera.action.CROP"); //indicate image type and Uri of image cropIntent.setDataAndType(picUri, "image/*"); //set crop properties cropIntent.putExtra("crop", "true"); cropIntent.putExtra("aspectX", 1); cropIntent.putExtra("aspectY", 1); cropIntent.putExtra("outputX", 256); cropIntent.putExtra("outputY", 256); // for save the image in same location with same name. File f = new File(Environment.getExternalStorageDirectory()+"your image location here"); cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); cropIntent.putExtra("output", Uri.fromFile(f)); cropIntent.putExtra("return-data", false); //start the activity - we handle returning in onActivityResult this.cordova.startActivityForResult((CordovaPlugin) this,cropIntent, 2); } public void onActivityResult(int requestCode, int resultCode, Intent intent) { //Log.e("final", String.valueOf(requestCode)); /*if(requestCode == 2){ //Create an instance of bundle and get the returned data Bundle extras = intent.getExtras(); //get the cropped bitmap from extras Bitmap thePic = extras.getParcelable("data"); }*/ } }
Remember to add this class to your CONFIG.XML and add the necessary permissions. Feel free to ask any doubts.