Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller-sized photos with very little or negligible loss in the quality of the image.
Step 1. Add it to your root build.gradle at the end of repositories:
allprojects{
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add it in your module's build.gradle:
dependencies {
implementation 'com.github.xswapsx:ImageCompressorLibrary:{latest-release}'
}
val compressedImagePath = ImageCompressor.compressImage("Your file's absolute path")
This library will overwrite the original file with the compressed file.