Skip to content

Instantly share code, notes, and snippets.

@mustafasevgi
Created March 11, 2015 08:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustafasevgi/04f4a62b055007e0ee46 to your computer and use it in GitHub Desktop.
Save mustafasevgi/04f4a62b055007e0ee46 to your computer and use it in GitHub Desktop.
Android crop intent parameters
Intent photoPickerIntent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
photoPickerIntent.putExtra("crop", "true");
photoPickerIntent.putExtra("outputX", 150);
photoPickerIntent.putExtra("outputY", 150);
photoPickerIntent.putExtra("aspectX", 1);
photoPickerIntent.putExtra("aspectY", 1);
photoPickerIntent.putExtra("scale", true);
photoPickerIntent.putExtra("crop", "true");
photoPickerIntent.putExtra("scaleUpIfNeeded", true);//learn it from gallery2 source code
photoPickerIntent.putExtra("max-width", 300);
photoPickerIntent.putExtra("max-height", 300);
photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
photoPickerIntent.putExtra("outputFormat",
Bitmap.CompressFormat.JPEG.toString());
startActivityForResult(photoPickerIntent, RESULT_LOAD_IMAGE);
@Shagunandroid
Copy link

Great Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment