A simple and minimal image picker and image cropping library for android
Installation • Usage • Contributing •
Installation (Kotlin DSL • Groovy )
- Install
jitpack
Locate your build.gradle.kts
file in the root project and add :
allprojects {
repositories {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") } // add this line
}
}
For those with a higher gradle version, find settings.gradle.kts
in the root project folder and
add :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") } // add this line
}
}
- Add Image Picker Dependency
In your app module find build.gradle.kts
and add :
implementation("com.github.tabasumu:image-picker:$version")
- Sync gradle and proceed use the library
- Install
jitpack
Locate your build.gradle
file in the root project and add :
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" } // add this line
}
}
For those with a higher gradle version, find settings.gradle
and add :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // add this line
}
}
- Add Image Picker dependency
In your app module find build.gradle
and add :
implementation 'com.github.tabasumu:image-picker:$version'
- create file_path.xml file under
/res/xml
- if
res/xml
does not exist create right click onres
folder and selectNew
thenAndroid Resource Directory
and selectxml
underResource Type
- if
- add the snippet below to
file_path.xml
file created above
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="images"
path="." />
</paths>
- in the apps'
AndroidManifest.xml
file add the following snippet referencing thefile_path.xml
created in step one above
<application>
...
<!-- add this part inside application tag -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
- Now you can use the library like below
ImagePicker.Builder(this)
.isCropping(true) // set to false by default
.cropType(ImagePicker.CropType.FREE) // set to free by default
.pickFrom(ImagePicker.PickFrom.ALL) // set to all by default
.resultUri { uri: Uri, file: File ->
// use uri or file depending on your needs
}.show()
new ImagePicker.Builder(this)
.isCropping(true) // set to false by default
.cropType(ImagePicker.CropType.FREE) // set to free by default
.pickFrom(ImagePicker.PickFrom.ALL) // set to all by default
.resultUri { uri: Uri, file: File ->
// use uri or file depending on your needs
}.show()
Your contributions are especially welcome. Whether it comes in the form of code patches, ideas, discussion, bug reports, encouragement or criticism, your input is needed.
Visit issues to get started.
Does the following
- get image from gallery or camera
- crops image
- returns uri or file path