I have to upload image captured from camera/gallery to server. In many apps I have seen images having resolution 1000X560 having size of 35 KB. While in my case, the image size goes upto 380 KB. My phone's camera captures images of resolution 2368X4224 of size < 2 MB. How can I have image at high resolution while keeping its size low? Here's what I have tried so far:
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(realPath, bmOptions);
bmOptions.inSampleSize = 1;
bmOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
bmOptions.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(realPath, bmOptions);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
I had read this documentation. The problem I am facing is how to decide min width and min height for the image.