12

How to reduce the size of camera picture while saving, using the camera action intent.

I was trying to use MediaStore.EXTRA_SIZE_LIMIT in putExtra of the camera action as below :

Intent captureintent =  new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);  
captureintent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
captureintent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
captureintent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, 0);
captureintent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, The Value to be Kept);

But this doesn't seem to work.

What is the efficient way to do so?

Shail Adi
  • 1,502
  • 4
  • 14
  • 35
  • `intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, MAXIMUM_VIDEO_SIZE);` `MAXIMUM_VIDEO_SIZE` is just the upper limit you want to impose on your picture size.Specify the maximum allowed size. – Vikalp Patel Jan 03 '13 at 16:01
  • `MAXIMUM_VIDEO_SIZE` is set based on the maximum picture your application is allowed to :) Just like twitter profile pic allowed only `1MB` or something like that – Vikalp Patel Jan 03 '13 at 16:04
  • Is there anything to control the size limit of image files? – Shail Adi Jan 03 '13 at 17:05
  • Try to place `MAXIMUM_IMAGE_SIZE` to something like these `captureintent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024*1024);` tht is `1MB` – Vikalp Patel Jan 03 '13 at 17:10
  • In Bytes 1024*1024 i.e 1MB :) – Vikalp Patel Jan 03 '13 at 17:56

1 Answers1

7

This is not possible on Android. ACTION_IMAGE_CAPTURE can only be used with MediaStore.EXTRA_OUTPUT, not the other three extras.

See http://developer.android.com/reference/android/provider/MediaStore.html.

Adam Nybäck
  • 845
  • 7
  • 13
  • @JoeBlow It's confusing because there is no single way to do it. You have to think about the ratio between width and height, possible cropping, memory consumption and possibly the size of the screen, see http://developer.android.com/training/displaying-bitmaps. – Adam Nybäck May 28 '14 at 17:46
  • 1
    Hi if you mean EXTRA_SIZE_LIMIT can't be used in conjunction with EXTRA_OUTPUT ... could you explain that a bit? Your link doesn't state that at all...??? – noelicus Dec 13 '16 at 16:29