从android中获取图像元数据

时间:2013-07-03 05:42:09

标签: android image metadata

我试图通过使用EXIFInterface获取jpg图像的元数据。 我能够获取数据,但我对flash数据感到困惑。 我怎么知道闪存是从元数据开/关? 这是我的代码..

public class MainActivity extends Activity {

TextView myTextView;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    myTextView = (TextView) findViewById(R.id.textview);

    // change with the filename & location of your photo file
    String filename = "/sdcard/DCIM/Camera/b.jpg";
    try {
        ExifInterface exif = new ExifInterface(filename);
        ShowExif(exif);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(this, "Error!", Toast.LENGTH_LONG).show();
    }
}

private void ShowExif(ExifInterface exif) {
    String myAttribute = "Exif information ---\n";
    myAttribute += getTagString(ExifInterface.TAG_DATETIME, exif);
    myAttribute += getTagString(ExifInterface.TAG_FLASH, exif);
    myAttribute += getTagString(ExifInterface.TAG_GPS_LATITUDE, exif);
    myAttribute += getTagString(ExifInterface.TAG_GPS_LATITUDE_REF, exif);
    myAttribute += getTagString(ExifInterface.TAG_GPS_LONGITUDE, exif);
    myAttribute += getTagString(ExifInterface.TAG_GPS_LONGITUDE_REF, exif);
    myAttribute += getTagString(ExifInterface.TAG_IMAGE_LENGTH, exif);
    myAttribute += getTagString(ExifInterface.TAG_IMAGE_WIDTH, exif);
    myAttribute += getTagString(ExifInterface.TAG_MAKE, exif);
    myAttribute += getTagString(ExifInterface.TAG_MODEL, exif);
    myAttribute += getTagString(ExifInterface.TAG_ORIENTATION, exif);
    myAttribute += getTagString(ExifInterface.TAG_WHITE_BALANCE, exif);
    myTextView.setText(myAttribute);
}

private String getTagString(String tag, ExifInterface exif) {
    return (tag + " : " + exif.getAttribute(tag) + "\n");
}

}

感谢

0 个答案:

没有答案