Editing metadata using ExifTool by Phil Harvey


Many times is a requirement to change the metadata information of a pdf file or image files. Here is a command line tool called ExifTool (http://www.sno.phy.queensu.ca/~phil/exiftool/) which read information from many available file types and edits some important formats check out the supported file types (http://www.sno.phy.queensu.ca/~phil/exiftool/#supported). Following is a Java code snippet which changes the Image Description tag in the EXIF header of an image.

String[] strArgs={“exiftool”,”-F”,”-exif:imagedescription=My Image Description” , <absolute image file path here>,”-o”,<result image absolute file path> };
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(strArgs);
p.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=””;
while((line=input.readLine())!=null){
System.out.println(line);
}
input.close();
p.destroy();

The above code creates a new file <result file> with only the Image Description changed to “My Image Description”, the output is also printed out on the console which should show 1 file(s) created. There are many command line options (http://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html) available to change almost every thing in the header. The latest version 8.5.1 was released on previous Saturday 12th March 2011 where as the recent production release was on 1st March 2011 check out the Version History here (http://www.sno.phy.queensu.ca/~phil/exiftool/history.html) .

Wiki Page: http://en.wikipedia.org/wiki/ExifTool

Advertisements

About Dominic

J for JAVA more about me : http://about.me/dominicdsouza
This entry was posted in Thechy Stuff. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s