Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android JPEG to Bitmap = reduction in size

I noticed that after I converted my jpeg file into a bitmap the size drops almost by half, is this normal? I doing something like this:

    bmp1 = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()
                            + "/Test/test" + System.currentTimeMillis()
                            + ".jpg");
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bmp1.compress(Bitmap.CompressFormat.JPEG, 100, stream);
    byte[] byteArray = stream.toByteArray();
    System.out.println(byteArray.length);
like image 633
Maurice Avatar asked Dec 06 '25 18:12

Maurice


1 Answers

Your code is decoding a jpeg into a bitmap and then re-compressing it into a jpeg again. The re-compression is likely to be reducing the file size, at the cost of also reducing the quality of the image.

Jpeg compression (even at quality 100) is not lossless.

like image 80
Rob Avatar answered Dec 08 '25 07:12

Rob