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

x33g5p2x  于2022-01-25 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(99)

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

Metadata.getDirectoriesOfType介绍

暂无

代码示例

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

/**
 * Determine if there is an extended XMP section based on the standard XMP part.
 * The xmpNote:HasExtendedXMP attribute contains the GUID of the Extended XMP chunks.
 */
@Nullable
private static String getExtendedXMPGUID(@NotNull Metadata metadata)
{
  final Collection<XmpDirectory> xmpDirectories = metadata.getDirectoriesOfType(XmpDirectory.class);
  for (XmpDirectory directory : xmpDirectories) {
    final XMPMeta xmpMeta = directory.getXMPMeta();
    try {
      final XMPIterator itr = xmpMeta.iterator(SCHEMA_XMP_NOTES, null, null);
      if (itr == null)
        continue;
      while (itr.hasNext()) {
        final XMPPropertyInfo pi = (XMPPropertyInfo) itr.next();
        if (ATTRIBUTE_EXTENDED_XMP.equals(pi.getPath())) {
          return pi.getValue();
        }
      }
    } catch (XMPException e) {
      // Fail silently here: we had a reading issue, not a decoding issue.
    }
  }
  return null;
}

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

List<Directory> dirs = metadata.getDirectoriesOfType(JpegDirectory.class).stream().collect(Collectors.toList());
  images.add(new Image(E.getFileName().toString(), FilenameUtils.getExtension(E.toFile().toString()), dirs));
} else {
  List<Directory> dirs = metadata.getDirectoriesOfType(PngDirectory.class).stream().collect(Collectors.toList());
  images.add(new Image(E.getFileName().toString(), FilenameUtils.getExtension(E.toFile().toString()), dirs));

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

// Extract metadata from the image
Metadata metadata = ImageMetadataReader.readMetadata(image);

// Iterate through any XMP directories we may have received
for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) {

  // Usually with metadata-extractor, you iterate a directory's tags. However XMP has
  // a complex structure with many potentially unknown properties. This doesn't map
  // well to metadata-extractor's directory-and-tag model.
  //
  // If you need to use XMP data, access the XMPMeta object directly.
  XMPMeta xmpMeta = xmpDirectory.getXMPMeta();

  // Iterate XMP properties
  XMPIterator itr = xmpMeta.iterator();
  while (itr.hasNext()) {
    XMPPropertyInfo property = (XMPPropertyInfo) itr.next();

    // Print details of the property
    System.out.println(property.getPath() + ": " + property.getValue());
  }
}

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

/**
 * Determine if there is an extended XMP section based on the standard XMP part.
 * The xmpNote:HasExtendedXMP attribute contains the GUID of the Extended XMP chunks.
 */
@Nullable
private static String getExtendedXMPGUID(@NotNull Metadata metadata)
{
  final Collection<XmpDirectory> xmpDirectories = metadata.getDirectoriesOfType(XmpDirectory.class);
  for (XmpDirectory directory : xmpDirectories) {
    final XMPMeta xmpMeta = directory.getXMPMeta();
    try {
      final XMPIterator itr = xmpMeta.iterator(SCHEMA_XMP_NOTES, null, null);
      if (itr == null)
        continue;
      while (itr.hasNext()) {
        final XMPPropertyInfo pi = (XMPPropertyInfo) itr.next();
        if (ATTRIBUTE_EXTENDED_XMP.equals(pi.getPath())) {
          return pi.getValue();
        }
      }
    } catch (XMPException e) {
      // Fail silently here: we had a reading issue, not a decoding issue.
    }
  }
  return null;
}

相关文章