0

I am capturing image from camera and onActivityResult(). I'm rescaling the image to 800 x 600 along with 70% compression factor. While I am doing so I am getting different image sizes for the same camera resolution.

Bitmap pic = BitmapFactory.decodeFile(myPath);
Bitmap bitmap = Bitmap.createScaledBitmap(pic, 800, 600, true);
OutputStream os = null;
File file = new File("MyFile.png");

try {
    os = new FileOutputStream(file);
    bitmap.compress(Bitmap.CompressFormat.JPEG,70,outputStream);
    os.flush();
    os.close();
    pic = null;

}catch (IOException e){ 
...
}

The data below is for 5 MP in both the cases but with different device having different android version. The output that i got was:

On GingerBread(2.3.3) the image size that got saved to the SDCard was 130 KB.

On JellyBean(4.2) the image size that got saved to the SDCard was 59.3 KB.

user987339
  • 10,519
  • 8
  • 40
  • 45
CodeWarrior
  • 5,026
  • 6
  • 30
  • 46
  • 7
    The compressibility, and hence resulting file size, depends on the image! – Ernest Friedman-Hill Oct 14 '13 at 10:56
  • it not depends on OS, it depends on camera of that particular device. – Sagar Maiyad Oct 14 '13 at 11:25
  • @ErnestFriedman-Hill is right. Imagine taking a picture of a black dot on a piece of paper, that can be compressed very heavily independent of resolution or OS because there isn't much information (variety, entropy, whatever) in the picture. – arynaq Oct 14 '13 at 11:58
  • Thank you for the quick response but both the images are identical, so in that case the compression should be the same. Right? – CodeWarrior Oct 14 '13 at 13:11
  • @Segi That idea crossed my mind so i checked that too but the resolution of the camera for 5 MP in both the cases was same, is there any other parameter of the camera that may cause this to happen? – CodeWarrior Oct 14 '13 at 13:13

1 Answers1

0

I was also observing the same thing happening when I was saving a bitmap loaded from resources when compressed and saved leading to different sized files on different Android OS. It is a little different problem than the one asked in the question but may be it gives some insight.

"Maybe you get your bitmap from a resource, in which case the bitmap dimension will depend on the phone screen density". The reasoning was part of answer to the following question:

How to make Bitmap compress without change the bitmap size?

Community
  • 1
  • 1