0

Below is my code. On clicking imageview camera will open and we will capture image. In the below onActivityResult the image size come as the size of thumbnail. I want the actual image size. How to do?

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) {
        Bitmap photo = (Bitmap) data.getExtras().get("data");
        if (CAMERA_REQUEST == 1) {
            ivBeforeLoading.setImageBitmap(photo);
            ivBeforeLoading.setBackgroundResource(0);
            imgBefLoad = photo;
        }
    }
}
Waqar UlHaq
  • 6,144
  • 2
  • 34
  • 42
Suresh
  • 701
  • 1
  • 6
  • 20

2 Answers2

1

-You need to get the full image path , not only the data from the intent extra , and then get your file from that path , only then you can get the real size of the picture . -you can use some picker library or you can just check this link

Dialog to pick image from gallery or from camera

you will find what you are looking for

B.mansouri
  • 376
  • 7
  • 16
0

Try this (how do I get file size of temp file in android?)

File file = new File(selectedPath);
int file_size = Integer.parseInt(String.valueOf(file.length()/1024));
Rec0iL
  • 34
  • 2