Skip to content

Commit

Permalink
Merge pull request #342 from nagix/issue-342
Browse files Browse the repository at this point in the history
Show XMP tags in ImageMetadataReader main method
  • Loading branch information
drewnoakes committed Apr 19, 2018
2 parents 91ffb19 + dfa3978 commit 070dc66
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Source/com/drew/imaging/ImageMetadataReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
import com.drew.metadata.exif.ExifIFD0Directory;
import com.drew.metadata.file.FileSystemMetadataReader;
import com.drew.metadata.file.FileTypeDirectory;
import com.drew.metadata.xmp.XmpDirectory;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;

/**
* Reads metadata from any supported file format.
Expand Down Expand Up @@ -306,6 +308,24 @@ public static void main(@NotNull String[] args) throws MetadataException, IOExce
}
}

if (directory instanceof XmpDirectory) {
Map<String, String> xmpProperties = ((XmpDirectory)directory).getXmpProperties();
for (Map.Entry<String, String> property : xmpProperties.entrySet()) {
String key = property.getKey();
String value = property.getValue();

if (value != null && value.length() > 1024) {
value = value.substring(0, 1024) + "...";
}

if (markdownFormat) {
System.out.printf("%s||%s|%s%n", directoryName, key, value);
} else {
System.out.printf("[%s] %s = %s%n", directoryName, key, value);
}
}
}

// print out any errors
for (String error : directory.getErrors())
System.err.println("ERROR: " + error);
Expand Down

0 comments on commit 070dc66

Please sign in to comment.