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; }
if (directory.containsTag(tagIdentifier)) {
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)); } } } }
public void handle(Directory directory, Metadata metadata) throws MetadataException { if (directory.containsTag(JpegCommentDirectory.TAG_COMMENT)) { metadata.add(TikaCoreProperties.COMMENTS, directory.getString(JpegCommentDirectory.TAG_COMMENT)); } } }
/** * 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)); } }
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")); } } }
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]); } } } } }
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) {
if (_currentDirectory.containsTag(tagId)) {
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) {
private boolean hasTags(Directory directory, int... tags) { for (int tag : tags) { if (directory.containsTag(tag)) { return true; } } return false; }
private boolean hasTags(Directory directory, int... tags) { for (int tag : tags) { if (directory.containsTag(tag)) { return true; } } return false; }
/*************************************************************************** * * **************************************************************************/ @Override public boolean containsTag (final int tag) { return (directory != null) ? directory.containsTag(tag) : false; }
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)); } } } }
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)); } } } }
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()); }
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()); }
public void handle(Directory directory, Metadata metadata) throws MetadataException { if (directory.containsTag(JpegCommentDirectory.TAG_COMMENT)) { metadata.add(TikaCoreProperties.COMMENTS, directory.getString(JpegCommentDirectory.TAG_COMMENT)); } } }
/** * 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)); } }
/** * 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)); } }