How to retrieve metadata from image file in Android

独自空忆成欢 提交于 2019-12-10 22:26:40

问题


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


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/4928660/how-to-retrieve-metadata-from-image-file-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!