How to reduce size of picture of camera in android

In my Application when i take the picture from camera, i needs to get the size of that picture and compress it,if it is more than the specified size. how should i know the size of image and compress it according to my application..

Please help me.


To get the height and width, you call:

Uri imagePath = Uri.fromFile(tempFile);//Uri from camera intent
//Bitmap representation of camera result
Bitmap realImage = BitmapFactory.decodeFile(tempFile.getAbsolutePath());

To resize the image, I just supply the resulting Bitmap into this method:

public static Bitmap scaleDown(Bitmap realImage, float maxImageSize,
            boolean filter) {
    float ratio = Math.min((float) maxImageSize / realImage.getWidth(),
            (float) maxImageSize / realImage.getHeight());
    int width = Math.round((float) ratio * realImage.getWidth());
    int height = Math.round((float) ratio * realImage.getHeight());

    Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width, height,
    return newBitmap;

The basic actually is just Bitmap.createScaledBitmap(). However, I wrap it to another method to scale it down proportionally.

Need Your Help

Business Objects WEBI 3 universes in one report

sap business-intelligence business-objects

this is bugging me since yesterday and I cannot work it out, hope you can help:

Cannot have plivo send sms working

php authentication curl plivo

I'm using Plivo PHP library to send sms via plivo.