Create a java api or parser

Started by mujer_esponja, June 11, 2010, 06:32:28 AM

Previous topic - Next topic

mujer_esponja

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!

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

rkalla

esponja,

I have release a library that provides a nice Java integration with 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, 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.)

Phil Harvey

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. :)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

rkalla

Sure, I'll reply to that other thread and see if I can help.