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

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

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

Directory.containsTag介绍

[英]Indicates whether the specified tag type has been set.
[中]指示是否已设置指定的标记类型。

代码示例

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

public boolean hasFollowerIfd()
{
  // In Exif, the only known 'follower' IFD is the thumbnail one, however this may not be the case.
  // UPDATE: In multipage TIFFs, the 'follower' IFD points to the next image in the set
  if (_currentDirectory instanceof ExifIFD0Directory || _currentDirectory instanceof ExifImageDirectory) {
    // If the PageNumber tag is defined, assume this is a multipage TIFF or similar
    // TODO: Find better ways to know which follower Directory should be used
    if (_currentDirectory.containsTag(ExifDirectoryBase.TAG_PAGE_NUMBER))
      pushDirectory(ExifImageDirectory.class);
    else
      pushDirectory(ExifThumbnailDirectory.class);
    return true;
  }
  // The Canon EOS 7D (CR2) has three chained/following thumbnail IFDs
  if (_currentDirectory instanceof ExifThumbnailDirectory)
    return true;
  // This should not happen, as Exif doesn't use follower IFDs apart from that above.
  // NOTE have seen the CanonMakernoteDirectory IFD have a follower pointer, but it points to invalid data.
  return false;
}

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

if (directory.containsTag(tagIdentifier)) {

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

private void set(Directory directory, Metadata metadata, int extractTag, Property metadataField) {
    if (directory.containsTag(extractTag)) {
      Matcher m = LEADING_NUMBERS.matcher(directory.getString(extractTag));
      if (m.matches()) {
        metadata.set(metadataField, m.group(1));
      }
    }
  }
}

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

public void handle(Directory directory, Metadata metadata) throws MetadataException {
    if (directory.containsTag(JpegCommentDirectory.TAG_COMMENT)) {
      metadata.add(TikaCoreProperties.COMMENTS, directory.getString(JpegCommentDirectory.TAG_COMMENT));
    }
  }
}

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

/**
 * EXIF may contain image description, although with undefined encoding.
 * Use IPTC for other annotation fields, and XMP for unicode support.
 */
public void handleCommentTags(Directory directory, Metadata metadata) {
  if (metadata.get(TikaCoreProperties.DESCRIPTION) == null &&
      directory.containsTag(ExifIFD0Directory.TAG_IMAGE_DESCRIPTION)) {
    metadata.set(TikaCoreProperties.DESCRIPTION,
        directory.getString(ExifIFD0Directory.TAG_IMAGE_DESCRIPTION));
  }
}

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

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.containsTag(IptcDirectory.TAG_KEYWORDS)) {
      String[] keywords = directory.getStringArray(IptcDirectory.TAG_KEYWORDS);
      for (String k : keywords) {
        metadata.add(TikaCoreProperties.SUBJECT, k);
      }
    }
    if (directory.containsTag(IptcDirectory.TAG_HEADLINE)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_HEADLINE));
    } else if (directory.containsTag(IptcDirectory.TAG_OBJECT_NAME)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_OBJECT_NAME));
    }
    if (directory.containsTag(IptcDirectory.TAG_BY_LINE)) {
      metadata.set(TikaCoreProperties.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
      metadata.set(IPTC.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
    }
    if (directory.containsTag(IptcDirectory.TAG_CAPTION)) {
      metadata.set(TikaCoreProperties.DESCRIPTION,
          // Looks like metadata extractor returns IPTC newlines as a single carriage return,
          // but the exiv2 command does not so we change to line feed here because that is less surprising to users                        
          directory.getString(IptcDirectory.TAG_CAPTION).replaceAll("\r\n?", "\n"));
    }
  }
}

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

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    //TODO: after upgrading metadataextractor, swap out
    //magic number with ExifDirectoryBase.TAG_PAGE_NUMBER
    if (directory.containsTag(297)) {
      int[] pageNums = directory.getIntArray(297);
      //pages can be in any order, take the max
      if (pageNums != null && pageNums.length > 1) {
        Integer curr = metadata.getInt(TIFF.EXIF_PAGE_COUNT);
        if (curr == null || curr < pageNums[1]) {
          metadata.set(TIFF.EXIF_PAGE_COUNT, pageNums[1]);
        }
      }
    }
  }
}

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

if (directory.containsTag(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL)) {
  original = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
if (directory.containsTag(ExifIFD0Directory.TAG_DATETIME)) {
  Date datetime = directory.getDate(ExifIFD0Directory.TAG_DATETIME);
  if (datetime != null) {

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

if (_currentDirectory.containsTag(tagId)) {

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

if (directory.containsTag(ExifSubIFDDirectory.TAG_EXPOSURE_TIME)) {
  Object exposure = directory.getObject(ExifSubIFDDirectory.TAG_EXPOSURE_TIME);
  if (exposure instanceof Rational) {
if (directory.containsTag(ExifSubIFDDirectory.TAG_FLASH)) {
  String flash = directory.getDescription(ExifSubIFDDirectory.TAG_FLASH);
  if (flash != null) {
if (directory.containsTag(ExifSubIFDDirectory.TAG_FNUMBER)) {
  Object fnumber = directory.getObject(ExifSubIFDDirectory.TAG_FNUMBER);
  if (fnumber instanceof Rational) {
if (directory.containsTag(ExifSubIFDDirectory.TAG_FOCAL_LENGTH)) {
  Object length = directory.getObject(ExifSubIFDDirectory.TAG_FOCAL_LENGTH);
  if (length instanceof Rational) {
if (directory.containsTag(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT)) {
  metadata.set(Metadata.ISO_SPEED_RATINGS, directory.getString(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT));
if (directory.containsTag(ExifIFD0Directory.TAG_MAKE)) {
  metadata.set(Metadata.EQUIPMENT_MAKE, directory.getString(ExifIFD0Directory.TAG_MAKE));
if (directory.containsTag(ExifIFD0Directory.TAG_MODEL)) {
  metadata.set(Metadata.EQUIPMENT_MODEL, directory.getString(ExifIFD0Directory.TAG_MODEL));
if (directory.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
  Object length = directory.getObject(ExifIFD0Directory.TAG_ORIENTATION);
  if (length instanceof Integer) {

代码示例来源:origin: org.modeshape/modeshape-sequencer-images

private boolean hasTags(Directory directory, int... tags) {
  for (int tag : tags) {
    if (directory.containsTag(tag)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: ModeShape/modeshape

private boolean hasTags(Directory directory, int... tags) {
  for (int tag : tags) {
    if (directory.containsTag(tag)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: it.tidalwave.image/image-core

/***************************************************************************
 *
 *
 **************************************************************************/
@Override
public boolean containsTag (final int tag)
 {
  return (directory != null) ? directory.containsTag(tag) : false;
 }

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

private void set(Directory directory, Metadata metadata, int extractTag, Property metadataField) {
    if (directory.containsTag(extractTag)) {
      Matcher m = LEADING_NUMBERS.matcher(directory.getString(extractTag));
      if (m.matches()) {
        metadata.set(metadataField, m.group(1));
      }
    }
  }
}

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

private void set(Directory directory, Metadata metadata, int extractTag, Property metadataField) {
    if (directory.containsTag(extractTag)) {
      Matcher m = LEADING_NUMBERS.matcher(directory.getString(extractTag));
      if (m.matches()) {
        metadata.set(metadataField, m.group(1));
      }
    }
  }
}

代码示例来源:origin: ModeShape/modeshape

private void setDoubleIfTagPresent( Node node,
                  String propertyName,
                  Directory directory,
                  int tag ) throws RepositoryException {
  if (!directory.containsTag(tag)) {
    return;
  }
  node.setProperty(propertyName, directory.getRational(tag).doubleValue());
}

代码示例来源:origin: org.modeshape/modeshape-sequencer-images

private void setDoubleIfTagPresent( Node node,
                  String propertyName,
                  Directory directory,
                  int tag ) throws RepositoryException {
  if (!directory.containsTag(tag)) {
    return;
  }
  node.setProperty(propertyName, directory.getRational(tag).doubleValue());
}

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

public void handle(Directory directory, Metadata metadata) throws MetadataException {
    if (directory.containsTag(JpegCommentDirectory.TAG_COMMENT)) {
      metadata.add(TikaCoreProperties.COMMENTS, directory.getString(JpegCommentDirectory.TAG_COMMENT));
    }
  }
}

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

/**
 * EXIF may contain image description, although with undefined encoding.
 * Use IPTC for other annotation fields, and XMP for unicode support.
 */
public void handleCommentTags(Directory directory, Metadata metadata) {
  if (metadata.get(TikaCoreProperties.DESCRIPTION) == null &&
      directory.containsTag(ExifIFD0Directory.TAG_IMAGE_DESCRIPTION)) {
    metadata.set(TikaCoreProperties.DESCRIPTION,
        directory.getString(ExifIFD0Directory.TAG_IMAGE_DESCRIPTION));
  }
}

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

/**
 * EXIF may contain image description, although with undefined encoding.
 * Use IPTC for other annotation fields, and XMP for unicode support.
 */
public void handleCommentTags(Directory directory, Metadata metadata) {
  if (metadata.get(TikaCoreProperties.DESCRIPTION) == null &&
      directory.containsTag(ExifIFD0Directory.TAG_IMAGE_DESCRIPTION)) {
    metadata.set(TikaCoreProperties.DESCRIPTION,
        directory.getString(ExifIFD0Directory.TAG_IMAGE_DESCRIPTION));
  }
}

相关文章