@Override public String toString() { return String.format("%s Directory (%d %s)", getName(), _tagMap.size(), _tagMap.size() == 1 ? "tag" : "tags"); } }
/** * Get the name of the {@link com.drew.metadata.Directory} in which the tag exists, such as * <code>Exif</code>, <code>GPS</code> or <code>Interoperability</code>. * * @return name of the {@link com.drew.metadata.Directory} in which this tag exists */ @NotNull public String getDirectoryName() { return _directory.getName(); }
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; } }
private static void writeHierarchyLevel(@NotNull Metadata metadata, @NotNull PrintWriter writer, @Nullable Directory parent, int level) { final int indent = 4; for (Directory child : metadata.getDirectories()) { if (parent == null) { if (child.getParent() != null) continue; } else if (!parent.equals(child.getParent())) { continue; } for (int i = 0; i < level*indent; i++) { writer.write(' '); } writer.write("- "); writer.write(child.getName()); writer.write(NEW_LINE); writeHierarchyLevel(metadata, writer, child, level + 1); } }
String directoryName = directory.getName(); for (Tag tag : directory.getTags()) { String tagName = tag.getTagName();
@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); } } }
public void onExtractionSuccess(@NotNull File file, @NotNull Metadata metadata, @NotNull String relativePath, @NotNull PrintStream log) { if (metadata.hasErrors()) { log.print(file); log.print('\n'); for (Directory directory : metadata.getDirectories()) { if (!directory.hasErrors()) continue; for (String error : directory.getErrors()) { log.printf("\t[%s] %s\n", directory.getName(), error); _errorCount++; } } } }
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 }
/** * A basic representation of the tag's type and value. EG: <code>[Exif IFD0] FNumber - f/2.8</code>. * * @return the tag's type and value */ @Override @NotNull public String toString() { String description = getDescription(); if (description == null) description = _directory.getString(getTagType()) + " (unable to formulate description)"; return "[" + _directory.getName() + "] " + getTagName() + " - " + description; } }
makernote = directory.getName().replace("Makernote", "").trim(); break;
@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(); } } } }
public String getName() { return dir.getName(); } }
@Override public String toString() { return String.format("%s Directory (%d %s)", getName(), _tagMap.size(), _tagMap.size() == 1 ? "tag" : "tags"); } }
/** * Get the name of the {@link com.drew.metadata.Directory} in which the tag exists, such as * <code>Exif</code>, <code>GPS</code> or <code>Interoperability</code>. * * @return name of the {@link com.drew.metadata.Directory} in which this tag exists */ @NotNull public String getDirectoryName() { return _directory.getName(); }
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); } } } }
public void onExtractionSuccess(@NotNull File file, @NotNull Metadata metadata, @NotNull String relativePath, @NotNull PrintStream log) { if (metadata.hasErrors()) { log.print(file); log.print('\n'); for (Directory directory : metadata.getDirectories()) { if (!directory.hasErrors()) continue; for (String error : directory.getErrors()) { log.printf("\t[%s] %s\n", directory.getName(), error); _errorCount++; } } } }
/** * A basic representation of the tag's type and value. EG: <code>[Exif IFD0] FNumber - f/2.8</code>. * * @return the tag's type and value */ @Override @NotNull public String toString() { String description = getDescription(); if (description == null) description = _directory.getString(getTagType()) + " (unable to formulate description)"; return "[" + _directory.getName() + "] " + getTagName() + " - " + description; } }
@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(); } } } }