ExifToolWrapper.getTagsFromFiles is not able to return All Tags. The original ExifTool util can do that (by not specifying any tag).
I changed ExifToolWrapper, see attachement, and tested it a very little bit.
These are the differences:
--- ExifToolWrapper.java (revision 228)
+++ ExifToolWrapper.java (working copy)
@@ -166,11 +166,23 @@
* files. This can be used for all non-binary tags that are
* given via ExifTool.
* @param images The images to read from
- * @param tagNames A set of all the names of tags to read.
+ * @param tagNames A set of all the names of tags to read. If null or empty, all tags will be returned.
* @return A map of tag names to values. Values can be empty, but should not be null.
*/
public Map<File, Map<String, String>> getTagsFromFiles(Collection<File> images, Set<String> tagNames){
Map<File, Map<String, String>> fileToTagValues = new HashMap<File, Map<String, String>>();
+
+ // Handle a request for all tags:
+ // tagNames is null, or tagNames is empty.
+ // To avoid NullPointerException, always create a tagNames
+ if (tagNames==null) {
+ // Make tagNames always valid, create empty Set
+ tagNames=new HashSet<String>(1); // create empty Set
+ }
+ // Handle request for All tags (as defined in ExifTool: -All)
+ if (tagNames.contains("All")) {
+ tagNames=new HashSet<String>(1); // create empty Set
+ }
if (images.size() == 0){
Log.warning("ExifToolWrapper: No files to read. Returning empty Map.");
@@ -184,6 +196,9 @@
for (String tagName : tagNames) {
command.add("-" + tagName);
}
+ //
+ // Add the file names to the command line
+ //
for (File image : images) {
command.add(image.getAbsolutePath());
}
@@ -224,7 +239,10 @@
if (currentFile != null){
if (fileToTagValues.get(currentFile) != null){
- if (tagNames.contains(tag)){
+ // A request for all tags should not test whether the found
+ // tag is contained in tagNames.
+ // 20100917 Carl van Denzen added the extra check
+ if (tagNames.contains(tag)||tagNames.isEmpty()){
fileToTagValues.get(currentFile).put(tag, value);
// Log.debug(tag + " = " + value + " in file " + currentFile.getAbsolutePath());
}
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"