I have one application in which mobile capture photo then it upload to the server. I want to check the size of photo first then reduce photo size to some particular size depending on actual photo size. Actually on server it not allow photo which have greater than some particular size (say 200 kb).
Or can I restrict the camera to capture photo only in particular size even some one change the setting of camera.
lot of question ask here which retrieve width and height of the photo. But I want to customize size in byte.
To open the camera I an using cameraIntent
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
here you can fix the size and maintain image Quality..
You can't dynamically specify the size of the resulting file and do a scaling. You have to re-size the height and width, which in turn would reduce the file size.
May be, a recurring approach, that can finally keep the file size within your limits would help. I can't think of any other solution. At-least, the Android SDK doesn't provide such an API.
If you want to retain the width/height, then you could try compressing techniques, and that would result in loss in quality, and eventually, file size. But again, there is no direct API to achieve this.
This is the only possible solution AFAIK, to reduce the size..