Android Image Compressor Library Kotlin + Java

Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller sized photos with very less or negligible loss in quality of the image. 


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

Let’s compress the image size!

Compress Image File

var compressedImageFile = Compressor(this).compressToFile(actualImageFile)

Compress Image File to Bitmap

var compressedImageBitmap = Compressor(this).compressToBitmap(actualImageFile)

I want custom Compressor!

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


Leave a Reply