How to retrieve metadata from image file in Androi

2019-07-03 08:00发布

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

2条回答
劳资没心,怎么记你
2楼-- · 2019-07-03 08:40

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.

查看更多
狗以群分
3楼-- · 2019-07-03 09:01

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);
查看更多
登录 后发表回答