Minifier is a lightweight (21KB) android library for image resizing, format changing and quality focusing in reduce file size.
With an image file, apply one or multiples transformations:
MinifierFactory.create(context)
.withImage(originalFile)
.addTransformations {
resize(1200, 720)
convertTo(CompressFormat.JPEG)
}
.minify {
onSuccess { minified -> /* success */ }
onFailure { error -> /* failure */ }
}
or use coroutines:
val minifiedFile: File = MinifierFactory.create(context)
.withImage(originalFile)
.addTransformations {
resize(1200, 720)
convertTo(CompressFormat.JPEG)
}
.minifyWith(Dispatchers.Default)
.onSuccess { minified -> /* success */ }
.onFailure { error -> /* failure */ }
- Resize
resize(1200, 720)
- Format
convertTo(CompressFormat.JPEG)
- Gray scale
colorGrayScale()
- Quality
quality(80)
- Project
build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Module
build.gradle
dependencies {
implementation 'com.github.jeziellago:image-minifier:0.2.0'
}