Himanshu Virmani Himanshu Virmani - 1 year ago 587
Android Question

Is com.android.camera.action.CROP not available for Android jelly bean 4.3?

I was using com.android.camera.action.CROP for cropping after taking pic using camera.

Below was my code which used to work earlier before 4.3.

Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
cropIntent.putExtra("outputX", Conf.getInt("IMAGE_WIDTH"));
cropIntent.putExtra("outputY", Conf.getInt("IMAGE_HEIGHT"));
startActivityForResult(cropIntent, CROP_REQUEST_CODE);

But now since android crop action takes you to gallery(because gallery is default with crop), this cropping method fails(photo is not saved to gallery).

Does any one knows a way out of this issue. Where I can use the crop on the photo taken from camera

Answer Source

Copying the answer from a similar question asked earlier..

Have you considered just using a library like this one:


I find the com.android.camera.action.CROP can sometimes behave differently from phone to phone and is not always available, so it could cause some problems for you anyway if you are looking to release it.


I have tested the above library with Android 4.3 and it works with no problem. You just need to add the library to your project.

You can then write your method in a very similar way:

private void performCrop(Uri picUri) {
//you have to convert picUri to string and remove the "file://" to work as a path for this library
String path = picUri.toString().replaceAll("file://", "");
try {
    int aspectX = 750;
    int aspectY = 1011;

    Intent intent = new Intent(this, CropImage.class);
    //send the path to CropImage intent to get the photo you have just taken or selected from gallery
    intent.putExtra(CropImage.IMAGE_PATH, path);

    intent.putExtra(CropImage.SCALE, true);

    intent.putExtra("aspectX", aspectX);
    intent.putExtra("aspectY", aspectY);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCurrentPhotoPath)));

    startActivityForResult(intent, CROP);
catch (ActivityNotFoundException anfe) {
    String errorMessage = "Your device doesn't support the crop action!";
    Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download