Search code examples
androidimageencodingcompressionjpeg

How to reduce size of JPEG Image in Android


In my application, I am invoking the camera application and taking a picture and saving it in a particular directory (E.g. /sdcard etc)

The picture is saved as a JPEG image. How do I reduce the size of the image? Is there any available image encoder or compression available?

I came across another posting at: Android Reduce Size Of Camera Picture

But this is scaling the image. I am looking for something that can compress or encode. Is it possible?

Thanks In Advance, Perumal


Solution

  • I am not sure anyway you can try this one.For reducing the size of the image first you should convert the image to bitmap before saving it to the particular directory, and compress the bitmap set the quality of the image and write it to the correct path.The quality of the image can be changed and hope this will help you to reduce the size of the image.

    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);` 
    

    API:

    compress (Bitmap.CompressFormat format, int quality, OutputStream stream)