zetbaitsu/Compressor: what one Gradle line actually buys you on Android
An android image compression library.
At a glance
- What is it?
- A Kotlin library that re-encodes image files before you upload them, configured through a chain of constraint calls inside a coroutine scope. The API surface is small and readable, but the docs leave error handling, EXIF behavior, and version compatibility entirely to you.
- Who is it for?
- Compressor is a reasonable fit if your Android app needs a handful of images re-encoded before upload and you are willing to own the edge cases. It is not a fit if you need documented exception handling, EXIF guarantees, or a release newer than March 2021.
- Can I use it commercially?
- Not without permission. GitHub finds no licence file in the repository, and without a licence all rights are reserved by default: you may read the code but not reuse it. Check the README, or ask the authors, before using it.
- Is it still maintained?
- Activity is slowing. The repository last received commits 8 months ago.
- What is it written in?
- Mainly Kotlin, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- zetbaitsu/Compressor7,229 ★ · +4
| Repository | 2026-09-23 | 2026-11-15 |
|---|---|---|
| zetbaitsu/Compressor | 7.2k | 7.2k |
4 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The Gradle coordinate is id.zelory, not zetbaitsu
The repository is zetbaitsu/Compressor, but the artifact you add comes from a different Maven group. The dependency block reads:
dependencies {
implementation 'id.zelory:compressor:3.0.1'
}So the group is id.zelory and the version is pinned to 3.0.1, which is also the newest tag in the release list. The checkout keeps two Gradle modules side by side: an app directory that exists to exercise the library, and a compressor directory holding the library code, alongside gradlew, gradlew.bat, build.gradle and settings.gradle. The default branch is master, and an older README_v2.md sits next to README.md for anyone still on the pre-coroutines API. Copyright in the README is held by Zetra, 2016, under the Apache License 2.0.
destination() moves the output path, the other calls change the encoding
One call with no configuration block is the shortest path:
val compressedImageFile = Compressor.compress(context, actualImageFile)Add a block and you are choosing between two kinds of change. destination(myFile) picks where the result lands:
val compressedImageFile = Compressor.compress(context, actualImageFile) {
default()
destination(myFile)
}Everything else changes how the pixels get encoded:
val compressedImageFile = Compressor.compress(context, actualImageFile) {
resolution(1280, 720)
quality(80)
format(Bitmap.CompressFormat.WEBP)
size(2_097_152) // 2 MB
}There is also a middle form that sets a width and a format in one call, default(width = 640, format = Bitmap.CompressFormat.WEBP). In the destination sample, default() comes first and destination(myFile) follows it.
A Constraint answers two questions, and isSatisfied decides when it runs
Custom behavior is added by implementing one interface with two methods:
class MyLowerCaseNameConstraint: Constraint {
override fun isSatisfied(imageFile: File): Boolean {
return imageFile.name.all { it.isLowerCase() }
}
override fun satisfy(imageFile: File): File {
val destination = File(imageFile.parent, imageFile.name.toLowerCase())
imageFile.renameTo(destination)
return destination
}
}isSatisfied() receives the image file and returns a Boolean, and that return value is what tells the library whether the file still needs work. satisfy() receives the same file and returns a File. You register yours with constraint(MyLowerCaseNameConstraint()) inside the block. One thing is worth noticing about the sample: it inspects the file name only and never looks at byte size, so a constraint written this way reports itself satisfied by any name it considers valid, no matter how large the image behind that name happens to be.
The sample Constraint discards the result of renameTo
The satisfy() implementation in the README builds a new File in the same parent directory with a lowercased name, calls renameTo on the original, and returns the new path. renameTo returns a Boolean, and the sample ignores it. The File it returns was constructed before the rename was attempted, so it exists as a path even when the move failed. If you copy this pattern for a constraint you depend on, check the return value yourself.
This is also a naming constraint rather than a size constraint, and no size-checking example appears anywhere in the README. Nothing in the interface forces isSatisfied() to look at file length. If your goal is capping upload size, the size(2_097_152) call is the piece aimed at bytes, and any custom constraint on top of it is code you write and test on your own.
Extensions on Compression compose with the built in calls
Extension functions can wrap a constraint so it reads like a named setting:
fun Compression.lowerCaseName() {
constraint(MyLowerCaseNameConstraint())
}
val compressedImageFile = Compressor.compress(context, actualImageFile) {
lowerCaseName() // your own extension
quality(80) // combine with compressor constraint
format(Bitmap.CompressFormat.WEBP)
}Note that lowerCaseName() is defined on Compression, the receiver of the configuration block, which is why it composes with the built in calls in the same block. The example deliberately mixes it with quality(80) and format(Bitmap.CompressFormat.WEBP), so a custom constraint and the library's own settings are meant to be layered rather than swapped. The README shows the constraint form used alongside the extension form, and both produce a File from the same compress() entry point.
compress() expects a coroutine scope, and Dispatchers.Main changes only the thread
Since the coroutines rewrite, the call belongs inside a scope:
// e.g calling from activity lifecycle scope
lifecycleScope.launch {
val compressedImageFile = Compressor.compress(context, actualImageFile)
}
// calling from global scope
GlobalScope.launch {
val compressedImageFile = Compressor.compress(context, actualImageFile)
}And there is one documented way to stay on the main thread:
val compressedImageFile = Compressor.compress(context, actualImageFile, Dispatchers.Main)lifecycleScope ties the work to a lifecycle owner, so a rotation or a finished activity can end it. GlobalScope has no such owner and outlives the screen that started it. Passing Dispatchers.Main does not change the lifetime of the job at all, it only changes the thread, so a large decode still runs against your UI thread for as long as it takes. The README does not say what happens to a destination file when the surrounding scope is cancelled, so do not assume a half written file gets cleaned up for you.
No documented exception type, and not a word about EXIF
Read the whole README and you will not find a statement about error handling. There is no try and catch around any sample call, no named exception type, and no documented result for a file the decoder cannot open. If your source path points at a HEIC file from a camera roll, or at a file another app deleted between the picker returning and your code running, you get no expected exception to catch and no guidance on the outcome.
Metadata is unmentioned as well. The configuration calls cover width, height, quality, format and byte size, and WEBP appears in the examples, but nothing states whether orientation tags and GPS coordinates survive the write. Losing them is the desired behavior for a photo upload pipeline and a bug in a gallery app, so the answer decides where this library fits. You will have to read the encoder source inside the compressor module to learn which one you are getting. The README also states no minimum Android API level, no Kotlin version, and no coroutines version.
The newest tag is from March 2021 while commits continued into 2026
The release list ends at v3.0.1, tagged March 22, 2021, with v2.1.1 published the same day and v3.0.0 from January 26, 2020. The last push on the default branch is dated March 5, 2026, so commits have continued for years past the last published artifact. The repository is not archived, and the dependency you add still resolves to that 2021 tag.
That gap matters for a library you intend to ship inside an app. The Gradle line pins 3.0.1, so the behavior you get is frozen at that release, and anything fixed afterward is reachable only by pointing at a commit or building the compressor module yourself. The tree carries a .travis.yml file, and the README's coverage badge points at codecov. The honest maintenance note for your own records is the March 5, 2026 commit date and nothing stronger.
Editorial conclusion
Compressor is a reasonable fit if your Android app needs a handful of images re-encoded before upload and you are willing to own the edge cases. It is not a fit if you need documented exception handling, EXIF guarantees, or a release newer than March 2021. Before adopting it, check the 3.0.1 tag date against your build, read the compressor module for encoder behavior on rotation and metadata, and write your own failure tests.
Frequently asked questions
What is the compressor?
In the zetbaitsu/Compressor repository, Compressor is an Android image compression library written in Kotlin that turns large photos into smaller files, and it is published under the Maven group id.zelory rather than the zetbaitsu namespace.
how to install compressor
For zetbaitsu/Compressor, installation is one Gradle dependency. Add implementation 'id.zelory:compressor:3.0.1' to the dependencies block of your Android module, then call Compressor.compress(context, actualImageFile) from a coroutine scope.
Does zetbaitsu/Compressor block the main thread?
The zetbaitsu/Compressor docs state that compress() should be called from a coroutine scope such as lifecycleScope, and that passing Dispatchers.Main as the third argument is the supported way to run it on the main thread instead.
What does zetbaitsu/Compressor do with image metadata?
The zetbaitsu/Compressor README does not mention EXIF, GPS, or orientation handling anywhere. The configuration calls it shows cover width, height, quality, format, and byte size only.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/zetbaitsu-compressor)Star history chart for your README
[](https://hysenlabs.com/projects/zetbaitsu-compressor)Was this useful?