org.homeunix.thecave.moss.util.image
Class ExifToolWrapper

java.lang.Object
  extended by org.homeunix.thecave.moss.util.image.ExifToolWrapper

public class ExifToolWrapper
extends java.lang.Object

Author:
wyatt A wrapper class for the excellent ExifTool utility by Phil Harvey (see http://owl.phy.queensu.ca/~phil/exiftool/). Allows you to read and write tags to files via a normal Java interface. This class can currently read binary data, but cannot write it. That functionality may be added in a later release.

Constructor Summary
ExifToolWrapper(java.io.File exifTool)
          Creates a new ExifTool wrapper, pointing to the ExifTool command line file at the given location.
 
Method Summary
 byte[] getBinaryTagFromFile(java.io.File image, java.lang.String tagName, int maxSize)
          Returns a byte array of a binary tag with the given name.
 java.util.Map<java.io.File,byte[]> getBinaryTagFromFiles(java.util.Collection<java.io.File> files, java.lang.String tagName)
           
 java.util.Map<java.lang.String,java.lang.String> getTagsFromFile(java.io.File image, java.util.Set<java.lang.String> tagNames)
           
 java.util.Map<java.io.File,java.util.Map<java.lang.String,java.lang.String>> getTagsFromFiles(java.util.Collection<java.io.File> images, java.util.Set<java.lang.String> tagNames)
          Returns a map of the given tag names and values for all given files.
 java.lang.String setTagsToFile(java.io.File image, java.util.Map<java.lang.String,java.lang.String> tags)
           
 java.lang.String setTagsToFileFromDatafile(java.io.File image, java.util.Map<java.lang.String,java.io.File> tags)
           
 java.lang.String setTagsToFiles(java.util.Collection<java.io.File> images, java.util.Map<java.lang.String,java.lang.String> tags)
          Sets the given tags to the file.
 java.lang.String setTagsToFilesFromDatafile(java.util.Set<java.io.File> images, java.util.Map<java.lang.String,java.io.File> tags)
          Sets the given tags in the scpecified images using a data file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExifToolWrapper

public ExifToolWrapper(java.io.File exifTool)
                throws java.io.FileNotFoundException
Creates a new ExifTool wrapper, pointing to the ExifTool command line file at the given location.

Parameters:
exifTool - The exiftool command line utility
Throws:
java.io.FileNotFoundException
Method Detail

getBinaryTagFromFile

public byte[] getBinaryTagFromFile(java.io.File image,
                                   java.lang.String tagName,
                                   int maxSize)
Returns a byte array of a binary tag with the given name. Can be used to load embedded thumbnails, etc

Parameters:
image - File to load from
tagName - Name of the tag to load
maxSize - The maximum size of the value. You can either approximate this, or get the exact value from the getTagsFromFile(), and parse the exact number.
Returns:

getBinaryTagFromFiles

public java.util.Map<java.io.File,byte[]> getBinaryTagFromFiles(java.util.Collection<java.io.File> files,
                                                                java.lang.String tagName)

getTagsFromFiles

public java.util.Map<java.io.File,java.util.Map<java.lang.String,java.lang.String>> getTagsFromFiles(java.util.Collection<java.io.File> images,
                                                                                                     java.util.Set<java.lang.String> tagNames)
Returns a map of the given tag names and values for all given files. This can be used for all non-binary tags that are given via ExifTool.

Parameters:
images - The images to read from
tagNames - A set of all the names of tags to read.
Returns:
A map of tag names to values. Values can be empty, but should not be null.

getTagsFromFile

public java.util.Map<java.lang.String,java.lang.String> getTagsFromFile(java.io.File image,
                                                                        java.util.Set<java.lang.String> tagNames)
Parameters:
image -
tagNames -
Returns:

setTagsToFiles

public java.lang.String setTagsToFiles(java.util.Collection<java.io.File> images,
                                       java.util.Map<java.lang.String,java.lang.String> tags)
Sets the given tags to the file.

Parameters:
image - File to save tags to
tags - Map of tags and associated values
Returns:
All the output of the exiftool command (TODO: boolean value to see if write was successful or not)

setTagsToFile

public java.lang.String setTagsToFile(java.io.File image,
                                      java.util.Map<java.lang.String,java.lang.String> tags)

setTagsToFilesFromDatafile

public java.lang.String setTagsToFilesFromDatafile(java.util.Set<java.io.File> images,
                                                   java.util.Map<java.lang.String,java.io.File> tags)
Sets the given tags in the scpecified images using a data file. We do ABSOLUTELY NO SANITY CHECKS that the tags you specify can be properly read in from the files you specify. Be sure you check that you are writing the correct values to the correct images, or you will lose data!

Parameters:
images - Set of images to update
tags - Set of tags and files to read each tag from.
Returns:

setTagsToFileFromDatafile

public java.lang.String setTagsToFileFromDatafile(java.io.File image,
                                                  java.util.Map<java.lang.String,java.io.File> tags)