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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With