I want to get the width and height of a photo (Image) given the path of the photo. Is there a way to do that without loading the photo to the memory?
Asked
Active
Viewed 1,018 times
2 Answers
3
Yes, just use BitmapFactory for this in following way:
Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
After this fields outHeight and outWidth of options will contain bitmap size. You can use decodeStream or other function, based on way you access the file, just don't forget to provide BitmapFactory.Options.

OleGG
- 8,589
- 1
- 28
- 34
1
try this
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap btemp = BitmapFactory.decodeFile(selectedImagePath,options);
after this use below code to get height and width:
options.outHeight for height
options.outWidth for width

Ramesh Solanki
- 2,961
- 4
- 28
- 44