首先是框架引入:
//图片压缩框架
compile 'com.zxy.android:tiny:0.0.6'
框架简单使用:
//图片压缩
private void crompressImage(String path, final FileCallBack fileCallBack) {
Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
Tiny.getInstance().source(path).asFile().withOptions(options).compress(new FileCallback() {
@Override
public void callback(boolean isSuccess, String outfile) {
//return the compressed file path
File fileCrompress = new File(outfile);
fileCallBack.onFile(fileCrompress);
}
});
}
记得在Application里面进行初始化:
在BaseApp 里面进行初始化 Tiny.getInstance().init(this);
简单粗暴,并且支持多图批量压缩。简直棒棒的!!