ExifTool Forum

ExifTool => Developers => Topic started by: mujer_esponja on June 11, 2010, 06:32:28 AM

Title: Create a java api or parser
Post by: mujer_esponja on June 11, 2010, 06:32:28 AM
Hi!
I would like to get the dates which are given to me by ExifTool in a java project, just for indexing.
But I haven't found any example of use or something like that.
Any clue, please??
Could I export the results to a file or something like that??
Help please!!!

Thanks in advance!
Title: Re: Create a java api or parser
Post by: Phil Harvey on June 11, 2010, 07:18:44 AM
Did you see the Moss or im4java links in the Programming section of the ExifTool home page (https://exiftool.org/index.html#related_prog)?

- Phil
Title: Re: Create a java api or parser
Post by: rkalla on August 21, 2011, 12:24:09 PM
esponja,

I have release a library that provides a nice Java integration with ExifTool (http://www.thebuzzmedia.com/software/exiftool-enhanced-java-integration-for-exiftool/). To answer your specific question, usage for getting the dates out of images would look something like this:


File[] images = new File("yourDir").listFiles();
ExifTool tool = new ExifTool(Feature.STAY_OPEN);

for(File f : images) {
  String date = tool.getImageMeta(f, Tag.DATE_TIME_ORIGINAL);
  // do something with the date
}

tool.close(); // optional


The library currently supports extraction for about 50 tags (http://www.thebuzzmedia.com/downloads/software/exiftool/javadoc/com/thebuzzmedia/exiftool/ExifTool.Tag.html), focusing on the most common EXIF tags used by iOS, Android, BlackBerry and standard point-and-shoot and DSLR cameras.

NOTE: The Feature.STAY_OPEN line just runs ExifTool in daemon mode, you can explicitly shut it down like I did in the example above, or if you want to save the instance for reuse later you can and the automatic cleanup thread will cleanup the host process and streams after a certain level of inactivity (default is 10mins). This is also harmless as re-using the class after its resources have been shut down simple re-creates them, you won't get any exceptions or failures, it just keeps things nice and tidy.

If you don't use the STAY_OPEN feature then there is nothing to cleanup as ExifTool is launched and shutdown for each call automatically.

(Phil, my apologies if you don't like replies on old threads like this, I just felt I had info to help here. Feel free to erase this if this if it wasn't appropriate.)
Title: Re: Create a java api or parser
Post by: Phil Harvey on August 21, 2011, 03:35:11 PM
Quote from: rkalla on August 21, 2011, 12:24:09 PM
(Phil, my apologies if you don't like replies on old threads like this, I just felt I had info to help here. Feel free to erase this if this if it wasn't appropriate.)

There is nothing wrong with responding to old posts.  Thanks for the link.  It looks like a useful interface.  I'll add it to the ExifTool home page.

Since you obviously have some Java expertise, perhaps you could also respond to this post (https://exiftool.org/forum/index.php/topic,3527.msg16021.html#msg16021). :)

- Phil
Title: Re: Create a java api or parser
Post by: rkalla on August 22, 2011, 12:00:13 AM
Sure, I'll reply to that other thread and see if I can help.