How to get metadata from an image file in Android

How to get information from metadata, such as format (jpeg, bmp, png, ..), width, height, etc. from Android image files?

+3
source share
2 answers

You can extract the width, height and MIME type of an image as follows:

    BitmapFactory.Options opts=new BitmapFactory.Options();
    opts.inJustDecodeBounds=true;
    BitmapFactory.decodeFile("/sdcard/path/to/imagefile.blah", opts);
    Log.i(TAG, "Mimetype:" + opts.outMimeType);
    Log.i(TAG, "Width:" + opts.outWidth);
    Log.i(TAG, "Height:" + opts.outHeight);
+3
source

Yes, try finding the ContentValues ​​class, the contentResolver () function, and the URI class. This should have the necessary information, no matter what you try to do.

0
source

Source: https://habr.com/ru/post/1790597/