Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeziellago/image-minifier
Minifier is a lightweight android library for image resizing, format changing and quality focusing in reduce file size 🖼.
https://github.com/jeziellago/image-minifier
android bitmap compression file image kotlin resize
Last synced: 4 days ago
JSON representation
Minifier is a lightweight android library for image resizing, format changing and quality focusing in reduce file size 🖼.
- Host: GitHub
- URL: https://github.com/jeziellago/image-minifier
- Owner: jeziellago
- License: apache-2.0
- Created: 2020-07-13T04:35:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-29T13:48:34.000Z (over 2 years ago)
- Last Synced: 2023-03-08T07:28:56.160Z (over 1 year ago)
- Topics: android, bitmap, compression, file, image, kotlin, resize
- Language: Kotlin
- Homepage:
- Size: 341 KB
- Stars: 66
- Watchers: 3
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Image Minifier
![CI](https://github.com/jeziellago/image-minifier/workflows/CI/badge.svg?branch=master)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:
```kotlin
MinifierFactory.create(context)
.withImage(originalFile)
.addTransformations {
resize(1200, 720)
convertTo(CompressFormat.JPEG)
}
.minify {
onSuccess { minified -> /* success */ }
onFailure { error -> /* failure */ }
}
```
or use coroutines:
```kotlin
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
```kotlin
resize(1200, 720)
```
- Format
```kotlin
convertTo(CompressFormat.JPEG)
```
- Gray scale
```kotlin
colorGrayScale()
```
- Quality
```kotlin
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'
}
```