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.