2016-11-07 25 views
0

找不到零件,以便以标记形式打印出方法getTagName()的整个数组,而不是字符串。如何通过此元数据提取器库查看exif标签的数组?

https://drewnoakes.com/code/exif/

try { 
    InputStream is = new URL("http://www.dbituser1.dbitmobileappchallenge.com/uploadimage1/uploads/sample_0%20-%20Copy.jpg").openStream(); 
    BufferedInputStream bis = new BufferedInputStream(is); 
    Metadata metadata = ImageMetadataReader.readMetadata(bis); 

    for (Directory directory : metadata.getDirectories()) { 
     for (Tag tag : directory.getTags()) { 
      //Toast.makeText(DetailsActivity.this, "" + tag.getTagName() +": " + tag.getDescription(), Toast.LENGTH_LONG).show(); 
      if (tag.getTagName().contains("ISO")) { 
       TextView text = (TextView) findViewById(R.id.textView); 
       text.setText("ISO: " + tag.getDescription()); 
      } 

      if (tag.getTagName().contains("Exposure")) { 
       Toast.makeText(DetailsActivity.this, "This is the Date: " + tag.getDescription(), Toast.LENGTH_LONG).show(); 
       //TextView text = (TextView) findViewById(R.id.textView1); 
       //text.setText("Exposure: " + tag.getDescription()); 
      } 
     } 
    } 
} catch (ImageProcessingException e) { 
} catch (IOException e) { 
} 

回答

0

如果你只需要两个值,不重复所有的人。相反,请直接拔出您要查找的特定目录,然后取出标签。

从您的代码看起来您​​需要ExifSubIfdDirectory

ExifSubIFDDirectory subIfd = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class); 

if (subIfd != null) { 
    // NOTE these values could be null if they aren't present in the image's metadata 
    Integer iso = subIfd.getInteger(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT); 
    Double exposureTime = subIfd.getDoubleObject(ExifSubIFDDirectory.TAG_EXPOSURE_TIME); 
} 
相关问题