/image-minifier

Minifier is a lightweight android library for image resizing, format changing and quality focusing in reduce file size 🖼.

Primary LanguageKotlinApache License 2.0Apache-2.0

Image Minifier

CI

Minifier is a lightweight (21KB) android library for image resizing, format changing and quality focusing in reduce file size.

How it works?

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 */ }

Transformations

  • Resize
resize(1200, 720)
  • Format
convertTo(CompressFormat.JPEG)
  • Gray scale
colorGrayScale()
  • Quality
quality(80)

Dependencies

  • Project build.gradle
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • Module build.gradle
dependencies {
    implementation 'com.github.jeziellago:image-minifier:0.2.0'
}