Kihyo Moon
Kihyo Moon

Reputation: 41

How to retrieve metadata from image file in Android

How can I retrieve metadata information such as format (jpeg, bmp, png, ..), width, height etc. from image files in Android environment?

Upvotes: 4

Views: 2681

Answers (2)

Captain Blammo
Captain Blammo

Reputation: 1897

You can extract the width, height, and MIME type of an image like this:

    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);

Upvotes: 5

jtt
jtt

Reputation: 13541

Yes, try looking up the ContentValues class, contentResolver() function, and the URI class. This should have the information you need do whatever you're trying to do.

Upvotes: 0

Related Questions