Image Picker Library for Android


Easy to use and customizable library Choose a photo from the gallery or take a photo with the camera. You can also crop and compress the image according to the size, resolution and size of the image.

  • Select an image from the gallery
  • Select an image in Google Drive
  • Taking pictures with the camera
  • Image cropping (cropping the image to the specified aspect ratio or allowing the user to select one)
  • Image compression (compressing the image according to the specified resolution and size)
  • Restore the result of the image as a file, the file path as string or Uri object
  • Permission to use the camera and memory pen

Use of

  1. Gradle dependency:allprojects {
    repositories {
    jcenter() // For the ImagePicker library, this security is sufficient. Although it is also published on the jitpac
    maven { url } / Don’t forget to add your project for uCrop – internal library

Implementation of com.github.Drjacky: ImagePicker: $libVersion.


If you want to get the result of the activity in a modern way (Lambda), install the InlineActivityResult library :

Implementation of com.github.florent37:inline-activity-result-kotlin:1.0.4.

  1. If you are targeting Android 10 or later (targetSdkVersion >= 29), set requestLegacyExternalStorage to true in the manifest file of your :

  1. The ImagePicker configuration is created using the Builder template.

.crop() //Crop image (optional), Check adjustment for more options
.cropOval() //One circle in the dimmed layer
.compress(1024) //Final image size is less than 1 MB (optional)
.maxResultSize(1080, 1080) //Final image resolution is less than 1080 x 1080 (optional)


.crop() //Crop image (optional), check customization for more options
.cropOval() //Fine darker image to have circle within
.compress(1024) //Final image size will be smaller than 1MB (optional)
.maxResultSize(1080, 1080) //Final image resolution will be smaller than 1080 x 1080 (optional)

  1. Treatment of resultsStandard method (preferred method)

Overwrite the OnActivityResult method and manage the result of the ImagePicker.

overwrite fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK) {
//Image Uri becomes non-zero on RESULT_OK
fall fileUri = data ?.data

// You can get the File object with the intention of
trap file:File = ImagePicker.getFile(data) !!!!.

// You can also specify the path to the file from the intention
fall filePath:String = ImagePicker.getFilePath(data)!
} else if (resultCode == ImagePicker.RESULT_ERROR) {
Toast.makeText(dit, ImagePicker.getError(data), Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(dit, cancelled task, Toast.LENGTH_SHORT).show()

Online method (with the InlineActivityResult library, only works with FragmentActivity and AppCompatActivity) (Not used with framing, see #32).

.compress(1024) //The final image size will be less than 1 MB (optional)
.maxResultSize(1080, 1080) //The final image resolution will be less than 1080 x 1080 (optional)
.start { resultCode, data ->
as (resultCode == Activity.RESULT_OK) {
//Image Uri will not be void on RESULT_OK
fall fileUri = data ?.data

// You can extract the File object from the expected file
val:File = ImagePicker.getFile(data).

// You can also change the file path of intention
trap filePath:String = ImagePicker.getFilePath(data)
} as (resultCode == ImagePicker.RESULTATEN_ERROR) {
Toast.makeText(context, ImagePicker.getError(data), Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(context, Task Cancelled, Toast.LENGTH_SHORT).show()


  • Select an image with GalleryImagePicker.with(this)
    .galleryOnly() // User can only start one image from Gallery
    .start() // Default request code is ImagePicker.REQUEST_CODE.
  • Capturing an image with CameraImagePicker.with(this)
    .cameraOnly() // The user can only capture an image with camera
  • Crop imageImagePicker.with(this)
    .crop() //Crop image and let the user choose the image size.
  • Crop an image with a fixed aspect ratio
    .crop(16f, 9f) //Crop an image with an aspect ratio of 16:9
  • Crop the square image (e.g. for the profile)ImagePicker.with(this)
    .cropSquare() //Cropping the square image, is identical to crop(1f, 1f)
  • Compress the image size (e.g. the image should not be larger than 1 MB)ImagePicker.with(this)
    .compress(1024) //Final image size will be smaller than 1 MB
  • Set the image resolutionImagePicker.with(this)
    .maxResultSize(620, 620) // The final image resolution will be less than 620 x 620
  • Intercept ImageProvider, can be used for analysisImagePicker.with (this)
    .setImageProviderIntercept ImageProvider
    Log.d (ImagePicker, Selected ImageProvider :
  • Specify the storage directory for captured, trimmed or compressed imagesImagePicker.with(this)
    // Check the path to the image storage directory
    .saveDir(File(Environment.getExternalStorageDirectory(), ImagePicker))
    // .saveDir(Environment.getExternalStorageDirectory()))
    // .saveDir(getExternalFilesDir(null) !!!!
  • Limit MIME types by gallery imageImagePicker.with(this)
    .galleryMimeTypes( //Exclude gif images
    mimeTypes = arrayOf(
  • You can also use the application code with ImagePickerImagePicker.with(this)
    .maxResultSize(620, 620)
    .start(101) //The application code is 101, you can use it in onActivityResult
  • Add the following settings to your color.xml file if you want to customize the uCrop activity.


  • Library – Android Kitkat 4.4+ (API 19)
  • Example – Android Kitkat 4.4+ (API 19)


Related Tags:

keemstar house,idubbbz age,how tall is leafyishere,keemstar dollar in the woods,h3h3 net worth,keemstar h3h3,keemstar socialblade,dramaalert,h3h3 age,keemstar lawyer,scarce net worth,keemstar sub count,keemstar net worth 2020,keemstar warzone wednesday,keemstar height and weight,markiplier height,keemstar twitter,pewdiepie height,keemstar weight loss,keemstar age,daniel keem net worth,keemstar net worth,keemstar daughter,pewdiepie net worth,keemstar girlfriend

You May Also Like