Crop an image

Take an image and crop it according to the user’s requirements. The output can be a URI or a (possibly) downsampled bitmap with the cropped image.

If the caller does not provide an image source as data then the activity should ask the user to pick an image using the Intent.ACTION_GET_CONTENT and mime-type image/*.

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT.


public void startCropAnImage(int outputX, int outputY, boolean scale, boolean scaleUpIfNeeded, int aspectX, int aspectY, int spotlightX, int spotlightY, boolean returnData, string output, boolean setAsWallpaper, boolean showWhenLocked, String outputFormat) {
    Intent intent = new Intent(""); 
    intent.setData(dataUri); // location of the image, can be empty 
    intent.putExtra("outputX", outputX); // int
    intent.putExtra("outputY", outputY); // int
    intent.putExtra("scale", scale); // boolean
    intent.putExtra("scaleUpIfNeeded", scaleUpIfNeeded); // boolean
    intent.putExtra("aspectX", aspectX); // int
    intent.putExtra("aspectY", aspectY); // int
    intent.putExtra("spotlightX", spotlightX); // int
    intent.putExtra("spotlightY", spotlightY); // int
    intent.putExtra("return-data", returnData); // boolean
    intent.putExtra("output", output); // string
    intent.putExtra("set-as-wallpaper", setAsWallpaper); // boolean
    intent.putExtra("showWhenLocked", showWhenLocked); // boolean
    intent.putExtra("outputFormat", outputFormat); // String
    if (intent.resolveActivity(getPackageManager()) != null) { 
      startActivityForResult(intent, REQUEST_CODE);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) { 
      // handle result

Example intent filter

<activity ...>
        <action android:name="" />
        <category android:name="android.intent.category.DEFAULT" />

Apps Providing an Implementation

Search on Github

Search on Google Play, AppBrain, Amazon App store or similar (not yet available - please make this happen!)

For Specification Writers

Edit on Github