0

I am using the Camera activity to capture the JPEG image. After image is saved and the controll is returned back to my application activity I would like to to determine the captured JPEG image dimensions without loading the whole image into memory via Bitmap object - can it be easily done somehow?

Is there any class, which reads the JPEG header and give me such information? I would like to avoid OOM conditions - but might be it is not a problem to load the whole image into memory - is it?

After knowing the dimensions I would like to use BitmapFactory to scale the image.

Thanks a lot

Kind Regards,

STeN

STeN
  • 6,262
  • 22
  • 80
  • 125
  • As a first approach I use http://stackoverflow.com/questions/672916/how-to-get-image-height-and-width-using-java. But I welcome any comments over this topic. – STeN Mar 07 '11 at 07:55

2 Answers2

1

Perhaps a work-around (see 2nd approach) by setting the quality?

bmp.compress(CompressFormat.JPEG, 75, pfos);

You would have to do a trial run to see what size the quality gets you though...

*The first approach creates a log file to get the width and height but not sure if you wanted the extra step of looking at a log file.

Rhea
  • 160
  • 6
1

You can use the ExifInterface class to read the image width and height.

Abhinav
  • 38,516
  • 9
  • 41
  • 49