如何在Android中从图像文件中检索元数据

如何在Android中从图像文件中检索元数据,android,image,metadata,Android,Image,Metadata,如何在Android环境中从图像文件中检索元数据信息,如格式(jpeg、bmp、png等)、宽度、高度等?是的,请尝试查找ContentValues类、contentResolver()函数和URI类。无论您想做什么,这都应该包含您需要的信息。您可以提取图像的宽度、高度和MIME类型,如下所示: BitmapFactory.Options opts=new BitmapFactory.Options(); opts.inJustDecodeBounds=true; Bit

如何在Android环境中从图像文件中检索元数据信息,如格式(jpeg、bmp、png等)、宽度、高度等?

是的,请尝试查找ContentValues类、contentResolver()函数和URI类。无论您想做什么,这都应该包含您需要的信息。

您可以提取图像的宽度、高度和MIME类型,如下所示:

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