Skip to content

Instantly share code, notes, and snippets.

@lenamuit
Created November 27, 2014 08:37
Show Gist options
  • Select an option

  • Save lenamuit/9cf40a8599bca9fcef23 to your computer and use it in GitHub Desktop.

Select an option

Save lenamuit/9cf40a8599bca9fcef23 to your computer and use it in GitHub Desktop.
Create image picker: resize and scale output.
Intent galleryIntent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
galleryIntent.setType("image/*");
galleryIntent.putExtra("crop", "true");
galleryIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
galleryIntent.putExtra("aspectX", 1);
galleryIntent.putExtra("aspectY", 1);
galleryIntent.putExtra("outputX", 512);
galleryIntent.putExtra("outputY", 512);
galleryIntent.putExtra("scaleUpIfNeeded", true);
galleryIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
galleryIntent.putExtra("return-data", false);
//Create chooser
Intent chooser = Intent.createChooser(galleryIntent,"Select images");
startActivityForResult(chooser, PICK_PHOTO);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment