whatisgithub

What is luban?

curzibn/luban — explained in plain English

Analysis updated 2026-06-24

13,733CAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

Kotlin Android library that compresses photos before upload using a WeChat-quality adaptive algorithm, processing images asynchronously in the background without blocking the user interface.

Mindmap

mindmap
  root((repo))
    What it does
      Compress Android images
      WeChat-quality output
      Async processing
    Tech Stack
      Kotlin
      TurboJPEG
      Kotlin Coroutines
    Compression Logic
      Adaptive by image size
      Pass-through if larger
    Use Cases
      Pre-upload compression
      Gallery optimization
      Batch processing
    Audience
      Android developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Compress user-uploaded photos before sending them to a server to reduce bandwidth and storage costs.

USE CASE 2

Batch-compress a list of images in the background on Android without blocking the UI using coroutines.

USE CASE 3

Reduce image file sizes before displaying them in a gallery or feed to improve app memory usage.

USE CASE 4

Integrate image compression in a Java Android project using the legacy Builder-style API.

What is it built with?

KotlinAndroidTurboJPEG

How does it compare?

curzibn/lubanjedisct1/libsodiumopenresty/openresty
Stars13,73313,67313,814
LanguageCCC
Setup difficultyeasymoderatemoderate
Complexity2/53/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
Use freely for any purpose including commercial apps, as long as you keep the copyright notice.

So what is it?

Luban 2 is an Android library that compresses photos and images before your app uploads or displays them. Modern phone cameras produce large image files, and sending these full-size files is slow and expensive. The library applies a compression algorithm designed to closely match the results you get when sending photos through WeChat Moments, producing small file sizes while keeping visual quality close to the original. The compression logic is adaptive: it analyzes each image based on its pixel count and dimensions, then applies a different strategy depending on what kind of image it is. Very small images are barely compressed to avoid quality loss. Standard photos get a balanced approach. Very large or panoramic images are compressed more aggressively. If the compressed result would actually be larger than the original, the library automatically passes through the original file instead, ensuring you never make things worse. This is a Kotlin rewrite of the original Luban library. It uses Kotlin Coroutines for asynchronous processing (so compression does not block the user interface) and TurboJPEG for the low-level encoding step. Kotlin projects can call it using a clean DSL or extension functions. Java projects can use a legacy Builder-style API. The library accepts files, URIs, and lists of images as input. Benchmark results in the README show the library compressing a 5.1 MB standard photo down to 305 KB, compared to WeChat reducing the same photo to 303 KB. For a 12.1 MB high-resolution image, the library produces 318 KB while WeChat produces 305 KB. The gap is small and the README is upfront that the algorithm is based on reverse engineering rather than access to WeChat internals. The library is available on Maven Central and works on Android API level 21 and above. It is licensed under the Apache 2.0 license.

Copy-paste prompts

Prompt 1
Show me how to use Luban 2 in a Kotlin Android app to compress a list of photos before uploading them to a server.
Prompt 2
I want to compress a URI to a file in Kotlin using Luban, show me the DSL syntax including a custom output file naming strategy.
Prompt 3
How do I use Luban 2 from a Java Android project using the Builder-style API?
Prompt 4
Configure Luban to skip compression for images smaller than 200 KB and only process larger files.
Prompt 5
Show me how to handle compression of multiple images in parallel using Luban 2 with Kotlin coroutines.

Frequently asked questions

What is luban?

Kotlin Android library that compresses photos before upload using a WeChat-quality adaptive algorithm, processing images asynchronously in the background without blocking the user interface.

What language is luban written in?

Mainly C. The stack also includes Kotlin, Android, TurboJPEG.

What license does luban use?

Use freely for any purpose including commercial apps, as long as you keep the copyright notice.

How hard is luban to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is luban for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.