Simple Photo Picker for Android. Supports jpeg, png, webp formats. Works on Android version 5 or higher.
✔️ Pick a picture from the gallery without storage permission.
✔️ Take a photo from the camera (camera permission is optional).
✔️ Rotate or crop the captured image.
✔️ Save the final image to the app's local directory so you can use it like a File, without a ContentResolver.
✔️ Transform result to Jpeg / PNG / WebP automatically if needed.
- Photopicker from Google is not good enough.
- Single entry point for camera/gallery images.
- Other libraries that I've tried have bugs and/or abandoned.
Why not photopicker from Google?
This library:
- Doesn't require Android 11 or Google Play services as the photopicker from Google does.
- Covers both gallery and camera sources of image.
- Has basic image editor (rotate / crop)
It doesn't have access to the file system of the device. The system component provides content to this lib instead.
See Intent.ACTION_OPEN_DOCUMENT for more details.
It's vaguely mentioned in the documentation. Unless you declare the camera permission in your app's manifest, you don't need to ask for runtime permission for this library. If you declare the camera permission (for other features in your app), this lib will ask for runtime permission automatically.
Thanks to uCrop library
For example in your activity:
// You can use the modern way to receive the result like this. Or you can use onActivityResult().
private val launcher = registerForActivityResult(StartActivityForResult()) {
it?.data?.data?.let { uri ->
// Done. Use the received uri with captured image inside.
imageView.setImageURI(uri)
}
}
ImagePickerPlus
.createIntent(
activity = this,
PickRequest(
source = PickSource.GALLERY, // or PickSource.CAMERA
transformation = ImageTransformation(
maxSidePx = 1024, // Or -1 if limit isn't needed
encodeToFormat = ImageFormat.JPEG, // Or null if transformation isn't needed
),
)
)
.let { launcher.launch(it) }
Sample application:
- Add
maven { url 'https://jitpack.io' }
to theallprojects
ordependencyResolutionManagement
section in top-levelbuild.gradle
orsettings.gradle
.
For example (settings.gradle
):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
- Add
implementation 'com.github.Andrew0000:ImagePickerPlus:$latest_version'
to the module-levelbuild.gradle
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.