Android常用图片压缩开源项目——Compressor

  • A+
所属分类:Android开源

 

dependencies {
    compile 'id.zelory:compressor:2.1.0'
}

Compress Image File

compressedImageFile = new Compressor(this).compressToFile(actualImageFile);

 

Compress Image File to Bitmap

compressedImageBitmap = new Compressor(this).compressToBitmap(actualImageFile);

 自定义:

compressedImage = new Compressor(this)
            .setMaxWidth(640)
            .setMaxHeight(480)
            .setQuality(75)
            .setCompressFormat(Bitmap.CompressFormat.WEBP)
            .setDestinationDirectoryPath(Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES).getAbsolutePath())
            .compressToFile(actualImage);

 

 

avatar