/Mozi

bitmap压缩,支持压缩到指定长宽,以及指定大小

Primary LanguageJava

Mozi

图片压缩,支持限制最大宽高,及最大图片大小 名字来源于中学课本,毕竟这个库脱胎于鲁班,哈哈

ScreenShot

screenshot_1 screenshot_2

Usage

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        compile 'com.github.sychaos:Mozi:1.0.3'
}

Sample Code

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    Mozi.with(MainActivity.this)
        .setMaxSize(maxSize)
        .setMaxWidth(width)
        .setMaxHeight(height)
        .load(list).get();

或者

    Mozi.with(MainActivity.this)
        .get(path);

两者都要写在子线程中

清理缓存

    Mozi.with(MainActivity.this)
        .clear();

Thanks

Luban

CompressHelper