Reputation: 11146
How can I find the resolution of any image in Android?
Upvotes: 7
Views: 15040
Reputation: 1327
If your image is on your res/drawable, you can use something like this:
Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.back);
bmp.getWidth(), bmp.getHeight();
Upvotes: 7
Reputation: 509
I think u are looking for this...
bitmap=MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
int imageWidth=bitmap.getWidth();
int imageHeight=bitmap.getHeight();
Try using this and let me know
Upvotes: 5
Reputation: 2257
The efficient way to get size of an image stored in disk (for example to get the size of an image file selected by the user for uploading) is to use BitmapFactory.Options
and set inJustDecodeBounds
to true. By doing so you will get the size(Width and Height) of an image file without loading the entire image into memory. This will help when want to check the resolution of an image before uploading.
String pickedImagePath = "path/of/the/selected/file";
BitmapFactory.Options bitMapOption=new BitmapFactory.Options();
bitMapOption.inJustDecodeBounds=true;
BitmapFactory.decodeFile(pickedImagePath, bitMapOption);
int imageWidth=bitMapOption.outWidth;
int imageHeight=bitMapOption.outHeight;
Upvotes: 18
Reputation: 779
You should definitely learn how to phrase a question! Since you didn't provide any information i can only guess what you are doing. Maybe you can try this ...
ImageView iv = new ImageView(this);
iv.getDrawable().getIntrinsicWidth();
iv.getDrawable().getIntrinsicHeight();
Upvotes: 3
Reputation: 24181
i think you can use the methodes :
myImageBitmap.getWidth();
myImageBitmap.getHeight();
Upvotes: 0