com.drew.metadata.Directory.getTags()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中com.drew.metadata.Directory.getTags()方法的一些代码示例,展示了Directory.getTags()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Directory.getTags()方法的具体详情如下:
包路径:com.drew.metadata.Directory
类名称:Directory
方法名:getTags

Directory.getTags介绍

[英]Returns an Iterator of Tag instances that have been set in this Directory.
[中]返回在此目录中设置的标记实例的迭代器。

代码示例

代码示例来源:origin: apache/nifi

private Map<String, String> getTags(Integer max, Metadata metadata) {
    Map<String, String> results = new HashMap<>();
    int i =0;

    for (Directory directory : metadata.getDirectories()) {
      for (Tag tag : directory.getTags()) {
        results.put(directory.getName() + "." + tag.getTagName(), tag.getDescription());

        if(max!=null) {
          i++;
          if (i >= max) {
            return results;
          }
        }
      }
    }

    return results;
  }
}

代码示例来源:origin: drewnoakes/metadata-extractor

for (Tag tag : directory.getTags()) {
  String tagName = tag.getTagName();
  String description = tag.getDescription();

代码示例来源:origin: drewnoakes/metadata-extractor

for (Tag tag : directory.getTags()) {
  String tagName = tag.getTagName();
  String directoryName = directory.getName();

代码示例来源:origin: stackoverflow.com

try
{
  // Extract metadata.
  Metadata metadata = ImageMetadataReader.readMetadata(new BufferedInputStream(new ByteArrayInputStream(imageData)), imageData.length);

  // Log each directory.
  for(Directory directory : metadata.getDirectories())
  {
    Log.d("LOG", "Directory: " + directory.getName());

    // Log all errors.
    for(String error : directory.getErrors())
    {
      Log.d("LOG", "> error: " + error);
    }

    // Log all tags.
    for(Tag tag : directory.getTags())
    {
      Log.d("LOG", "> tag: " + tag.getTagName() + " = " + tag.getDescription());
    }
  }
}
catch(Exception e)
{
  // TODO: handle exception
}

代码示例来源:origin: drewnoakes/metadata-extractor

@Override
public void onExtractionSuccess(@NotNull File file, @NotNull Metadata metadata, @NotNull String relativePath, @NotNull PrintStream log)
{
  super.onExtractionSuccess(file, metadata, relativePath, log);
  for (Directory directory : metadata.getDirectories()) {
    for (Tag tag : directory.getTags()) {
      // Only interested in unknown tags (those without names)
      if (tag.hasTagName())
        continue;
      HashMap<Integer, Integer> occurrenceCountByTag = _occurrenceCountByTagByDirectory.get(directory.getName());
      if (occurrenceCountByTag == null) {
        occurrenceCountByTag = new HashMap<Integer, Integer>();
        _occurrenceCountByTagByDirectory.put(directory.getName(), occurrenceCountByTag);
      }
      Integer count = occurrenceCountByTag.get(tag.getTagType());
      if (count == null) {
        count = 0;
        occurrenceCountByTag.put(tag.getTagType(), 0);
      }
      occurrenceCountByTag.put(tag.getTagType(), count + 1);
    }
  }
}

代码示例来源:origin: drewnoakes/metadata-extractor

for (Tag tag : directory.getTags()) {
  if (tag.getTagType() == ExifDirectoryBase.TAG_DATETIME) {
    dateTime = tag.getDescription();

代码示例来源:origin: drewnoakes/metadata-extractor

String directoryName = directory.getName();
for (Tag tag : directory.getTags()) {
  String tagName = tag.getTagName();
  String description;

代码示例来源:origin: drewnoakes/metadata-extractor

@Override
  public void onExtractionSuccess(@NotNull File file, @NotNull Metadata metadata, @NotNull String relativePath, @NotNull PrintStream log)
  {
    super.onExtractionSuccess(file, metadata, relativePath, log);
    // Iterate through all values, calling toString to flush out any formatting exceptions
    for (Directory directory : metadata.getDirectories()) {
      directory.getName();
      for (Tag tag : directory.getTags()) {
        tag.getTagName();
        tag.getDescription();
      }
    }
  }
}

代码示例来源:origin: apache/tika

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.getTags() != null) {
      for (Tag tag : directory.getTags()) {
        metadata.set(tag.getTagName(), tag.getDescription());
      }
    }
  }
}

代码示例来源:origin: apache/tika

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.getTags() != null) {
      for (Tag tag : directory.getTags()) {
        String name = tag.getTagName();
        if (!MetadataFields.isMetadataField(name) && tag.getDescription() != null) {
          String value = tag.getDescription().trim();
          if (Boolean.TRUE.toString().equalsIgnoreCase(value)) {
            value = Boolean.TRUE.toString();
          } else if (Boolean.FALSE.toString().equalsIgnoreCase(value)) {
            value = Boolean.FALSE.toString();
          }
          metadata.set(name, value);
        }
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

for (Directory directory : metadata.getDirectories()) {
  for (Tag tag : directory.getTags()) {
    System.out.println(tag);
  }
}

代码示例来源:origin: stackoverflow.com

try {
     InputStream is = new URL("your image url").openStream();
     BufferedInputStream bis = new BufferedInputStream(is);
     Metadata metadata = ImageMetadataReader.readMetadata(bis,true);
 for (Directory directory : metadata.getDirectories()) {
 for (Tag tag : directory.getTags()) {
   System.out.println(tag);
 }
}
     }
   catch (ImageProcessingException e){}
   catch (IOException e) {}

代码示例来源:origin: stackoverflow.com

try {
     InputStream is = new URL("your image url").openStream();
     BufferedInputStream bis = new BufferedInputStream(is);
     Metadata metadata = ImageMetadataReader.readMetadata(bis,true);
  for (Directory directory : metadata.getDirectories()) {
   for (Tag tag : directory.getTags()) {
    System.out.println(tag);
   }
  }
 }catch (ImageProcessingException e){}
  catch (IOException e) {}

代码示例来源:origin: stackoverflow.com

try {
     InputStream is = new URL("your image url").openStream();
     BufferedInputStream bis = new BufferedInputStream(is);
     Metadata metadata = ImageMetadataReader.readMetadata(bis,true);
 for (Directory directory : metadata.getDirectories()) {
 for (Tag tag : directory.getTags()) {
   System.out.println(tag);
 }
}
     }
   catch (ImageProcessingException e){}
   catch (IOException e) {}

代码示例来源:origin: org.apache.tika/tika-parsers

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.getTags() != null) {
      for (Tag tag : directory.getTags()) {
        metadata.set(tag.getTagName(), tag.getDescription());
      }
    }
  }
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-parsers

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.getTags() != null) {
      for (Tag tag : directory.getTags()) {
        metadata.set(tag.getTagName(), tag.getDescription());
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

File pic = new File("C:/myPicture.jpg"); 
Metadata metadata = ImageMetadataReader.readMetadata(pic);
    for (Directory directory : metadata.getDirectories()) {
      for (Tag tag : directory.getTags()) {
        System.out.println(tag + " - " +tag.getTagType());
      }
    }

代码示例来源:origin: perfectsense/dari

private void populateMetadata(Metadata metadata) {
  for (Iterator<?> di = metadata.getDirectories().iterator(); di.hasNext();) {
    Directory directory = (Directory) di.next();
    Map<String, String> tags = new HashMap<String, String>();
    put(directory.getName(), tags);
    for (Iterator<?> ti = directory.getTags().iterator(); ti.hasNext();) {
      Tag tag = (Tag) ti.next();
      try {
        tags.put(tag.getTagName(), directory.getDescription(tag.getTagType()));
      } catch (Exception error) {
        errors.add(error);
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

Metadata metadata = ImageMetadataReader.readMetadata(file);
Iterable<Directory> directories = metadata.getDirectories();
Iterator<Directory> iterator = directories.iterator();
while(iterator.hasNext()) {
  Directory dir = iterator.next();
  Collection<Tag> tags = dir.getTags();
  for(Tag tag: tags) {
    System.out.println(tag.getTagName() + "  " + tag.getDescription() + " " + tag.getTagTypeHex());
  }
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

@Override
  public void onExtractionSuccess(@NotNull File file, @NotNull Metadata metadata, @NotNull String relativePath, @NotNull PrintStream log)
  {
    super.onExtractionSuccess(file, metadata, relativePath, log);
    // Iterate through all values, calling toString to flush out any formatting exceptions
    for (Directory directory : metadata.getDirectories()) {
      directory.getName();
      for (Tag tag : directory.getTags()) {
        tag.getTagName();
        tag.getDescription();
      }
    }
  }
}

相关文章