ImagePicker
Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera. It also allows to Crop and Compresses the Image based on Aspect Ratio, Resolution and Image Size.
?Features
- Pick Gallery Image
- Pick Image from Google Drive
- Capture Camera Image
- Crop Image(Crop image based on provided aspect ratio or let user choose one)
- Compress Image(Compress image based on provided resolution and size)
- Retrive Image Result as File, File Path as String or Uri object
- Handle Runtime Permission for Camera and Storage
?Preview
Profile Image Picker | Gallery Only | Camera Only |
---|---|---|
![]() |
![]() |
![]() |
?Usage
-
Gradle dependency:
If you want to get the activity result inline in a modern way (lambda) install InlineActivityResult library:
-
If you target Android 10 or higher(targetSdkVersion >= 29), set the value of
requestLegacyExternalStorage
to true in your app's manifest file: -
The ImagePicker configuration is created using the builder pattern.
Kotlin
Java
-
Handling results
Default method(Preferred way)
OverrideonActivityResult
method and handle ImagePicker result.Inline method (with InlineActivityResult library, Only Works with FragmentActivity and AppCompatActivity) (Not to be used with crop. See #32)
?Customization
-
Pick image using Gallery
-
Capture image using Camera
-
Crop image
-
Crop image with fixed Aspect Ratio
-
Crop square image(e.g for profile)
-
Compress image size(e.g image should be maximum 1 MB)
-
Set Resize image resolution
-
Intercept ImageProvider, Can be used for analytics
-
Specify Directory to store captured, cropped or compressed images
-
Limit MIME types while choosing a gallery image
-
You can also specify the request code with ImagePicker
-
Add Following parameters in your colors.xml file, If you want to customize uCrop Activity.
?Compatibility
- Library - Android Kitkat 4.4+ (API 19)
- Sample - Android Kitkat 4.4+ (API 19)