Giter Club home page Giter Club logo

exiftool's Introduction

ExifTool - Enhanced Java Integration for Phil Harvey's ExifTool.

Changelog
---------
1.2 (In progress...)
	* Added support for the "CreationDate" QuickTime tag to the Tag enum.
	* Merged support for WRITING meta tags from Fabien Vauchelles

1.1
	* Initial public release.


License
-------
This library is released under the Apache 2 License. See LICENSE.


Description
-----------
This project represents the most robust Java integrations with Phil Harvey's 
excellent ExifTool available.

The goal of this project was to provide such a tight, well designed and performant
integration with ExifTool that any Java developer using the class would have no
idea that they weren't simply calling into a standard Java library while still
being able to leverage the unmatched robustness of ExifTool.

All concepts of external process launching, management, communication, tag
extraction, value conversion and resource cleanup are abstracted out by this 
project and all handled automatically for the caller.

Even when using ExifTool in "daemon mode" via the -stay_open True command line
argument, this project hides all the details required to make that work, 
automatically re-using the daemon process as well as eventually cleaning it up 
automatically along with supporting resources after a defined interval of 
inactivity so as to avoid resource leaks.

The set of EXIF tags supported out of the box is based on the EXIF tags supported
by the most popular mobile devices (iPhone, Android, BlackBerry, etc.) as well
as some of the most popular cameras on the market (Canon point and shoot as well
as DSLR).

And lastly, to ensure that integration with the external ExifTool project is as
robust and seamless as possible, this class also offers extensive pre-condition
checking and error reporting during instantiation and use.

For example, if you specify that you want to use Feature.STAY_OPEN support, the
ExifTool class will actually check the native ExifTool executable for support 
for that feature before allowing the feature to be turned on and report the 
problem to the caller along with potential work-arounds if necessary.

Additionally, all external calls to the process are safely wrapped and reported
with detailed exceptions if problems arise instead of just letting unknown
exceptions bubble up from the unknown system depths to the caller.

All the exceptions and exceptional scenarios are well-documented in the Javadoc
along with extensive implementation details for anyone wanting to know more about
the project.


Example
-------
Usage is straight forward, let's say we wanted to get the GPS coordinates out of 
an image:

  File image = // path to some image
  ExifTool tool = new ExifTool();
  
  Map<Tag, String> valueMap = 
  	tool.getImageMeta(image, Tag.GPS_LATITUDE, Tag.GPS_LONGITUDE);
  	
  System.out.println("Lat: " + valueMap.get(Tag.GPS_LATITUDE) +  
  					 ", Long: " + valueMap.get(Tag.GPS_LONGITUDE));

The fundamentals of use is that you give ExifTool a File handle to the image you
want to query as well as a list of Tags you want to pull values from it for and
it will give you back the results in a Map.

If you want to use ExifTool in daemon mode, you only change one line:

  ExifTool tool = new ExifTool(Feature.STAY_OPEN);
  
and then keep that "tool" reference around and re-use it as necessary. Under the
covers the ExifTool class will re-use the same ExifTool process for all the queries,
usually taking 1/20th or 1/30th the time to complete.


Performance
-----------
You can benchmark the performance of this ExifTool library on your machine by
running the Benchmark class under the /test/java repository. 

Here is an example output on my Core2 Duo 3.0Ghz E6850 w/ 12GB of Ram:

Benchmark [tags=49, images=10, iterations=25]
	250 ExifTool process calls, 12250 total operations.

	[-stay_open False]
		Elapsed Time: 97823 ms (97.823 secs)
	[-stay_open True]
		Elapsed Time: 4049 ms (4.049 secs - 24.159792x faster)

You can see that utilizing the -stay_open functionality provided in ExifTool
you can realize magnitudes times more performance.

Also the bigger of a test you run (more iterations) the bigger the performance
margin increases.


History
-------
This ExifTool library was incubated within imgscalr as an extension library that
I originally intended to be a simple way to pull the 'Orientation' EXIF flag out
of images in order to service automatic orientation support in imgscalr. After 
working on the integration layer for a few days I realized the potential for the
class and the opportunity to provide the best Java integration with ExifTool
available today.

From there I branched the code into its own project (the one you are looking at)
and continued to work on making the implementation as robust as possible.

Once the project had been branched, many of the more advanced features like
daemon mode support, automatic resource cleanup thread, most-popular-tags support,
tag value parsing, etc. all became self evident additions to the class to make
usage as easy and seamless as possible for Java developers.

My goal was ALWAYS to provide a class so well designed and performant that any
Java developer using it, wouldn't even realize they weren't using a Java library.


Troubleshooting
---------------
Below are a few common scenarios you might run into and proposed workarounds for
them.

	* I keep getting UnsupportedFeatureException exceptions when running ExifTool
	with Feature.STAY_OPEN support.
	
	This exception will only be raised when you attempt to use a Feature that
	the underlying ExifTool doesn't support. This means you either need to upgrade
	your install of ExifTool or skip using the feature.
	
	
	* I downloaded the newest version of ExifTool, but I keep getting 
	UnsupportedFeatureExceptions.
	
	What is probably happening is that your host system already had ExifTool
	installed and the default EXIF_TOOL_PATH is simply running the command "exiftool"
	which executes the one in the system path, not the newest version you may have
	just downloaded.
	
	You can confirm this by typing 'which exiftool' to see which one is getting
	launched. You can also point the ExifTool class at the correct version by
	setting the "exiftool.path" system property to point at it, e.g.:
	java -Dexiftool.path=/path/to/exiftool com.myco.MyApp


	* Can the ExifTool class support parsing InputStreams instead of File 
	representations of images?
	
	No. Phil has mentioned that enabling daemon mode disables the ability to 
	stream bytes to ExifTool to process for EXIF data (because ExifTool listens
	on the same input stream for processing commands and a terminating -execute
	sequence, it can't also listen for image byte[] data).
	
	Because of this and because of the expectation that ExifTool in daemon mode
	will be the primary use-case for this class, limited support for InputStream
	parsing was designed out of this class.
	
	
	* Do I need to manually call close() to cleanup a daemon ExifTool?
	
	This is done automatically for you via the cleanup thread the class employs
	when a daemon instance of ExifTool is created. Unless you modified the
	"exiftool.processCleanupDelay" system property and set it to 0 or less, the
	automatic cleanup thread is enabled and will clean up those resources for
	you after the specified amount of inactivity.
	
	If you DID disable the cleanup thread by setting "exiftool.processCleanupDelay"
	to 0, then yes, you need to call close() manually when done to cleanup those
	resources.
	
	
	* Is it better to manage cleanup myself or let the cleanup thread do it?
	
	It is better (and more consistent) to let the cleanup thread handle cleanup
	for you. You can always adjust the inactivity interval it uses by adjusting
	the value for the "exiftool.processCleanupDelay" system property, but by
	default the cleanup thread waits for 10 minutes of total inactivity before
	cleaning up the resources. That should be good in most cases, but you could
	always set that higher to something like an hour or more if you wish.
	
	If you really want to disable it and manage everything yourself, that is fine. 
	Just remember to be consistent.
	

Reference
---------
ExifTool by Phil Harvey - http://www.sno.phy.queensu.ca/~phil/exiftool/

exiftool's People

Contributors

gwinstanley avatar justin808 avatar mjeanroy avatar rkalla avatar sam avatar sw360cab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exiftool's Issues

Read whole XMP from DNG

I would be nice to be able to use the wrapper to extract a complete XMP-record from a DNG file and use the stay open feature as well.

-b -xmp -w! .xmp -ext DNG -r "" + rawname + """;

It would be even better to get this XMP data directly as ByteStream / String.

Thank you very much for considering!

Ability to extract Previews as BufferedImage

I would like to use this wrapper for extracting JPG previews from RAW files and use the stay-open feature to increase performance:

-if $jpgfromraw -b -overwrite_original -jpgfromraw -w "" + jpgname + "" -execute -if $previewimage -b -overwrite_original -previewimage -w "" + jpgname +"";

it would be best to be able to get the result directly as bufferedImage or bytestream without being forced to let exiftool write an intermediate jpg (performance)

Keywords could not be extracted

Hello,

I would like to use ExifTool to extract keywords from images. I tried using the native exiftool binary and got this from my test image:

dvrslype@laptop-dieter:/tmp$ exiftool -all a.jpeg
ExifTool Version Number : 9.04
File Name : a.jpeg
Directory : .
File Size : 544 kB
File Modification Date/Time : 2013:09:25 17:16:35+02:00
File Access Date/Time : 2013:09:25 17:18:35+02:00
File Permissions : rw-rw-r--
File Type : JPEG
MIME Type : image/jpeg
Current IPTC Digest : b861196cbed57a77955fb1b5ce222996
Keywords : TST3###TST2###TST1
Caption-Abstract : brugge_keywords.jpg
Application Record Version : 4
DCT Encode Version : 100
APP14 Flags 0 : [14]
APP14 Flags 1 : (none)
Color Transform : YCbCr
Image Width : 640
Image Height : 800
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:4:4 (1 1)
Image Size : 640x800

But when I use ExifTool to extract the keywords information, getImageMeta returns no result. I tried requesting all possible metadata (by adding all enums ExifTool.Tag.* to the getImageMeta method), and that only returns IMAGE_WIDTH and IMAGE_HEIGHT. How can I fix this? Is there a version conflict or so (I'm using the exiftool binary version 9.04 and 1.1 version of ExifTool).

regards,

dvrslype

PS: example image in attachment:

a

checkFeatureSupport version comparison

I am using version 10.01 of exiftool.
I constructed the ExifTool with Feature.STAY_OPEN.
The version compare section of the checkFeatureSupport method uses a string compare and it returns false for supported.
Please change the versions to double or float for the comparison.

Existing code
if (ver != null && ver.compareTo(feature.version) >= 0) {
supported = Boolean.TRUE;
log("\t\tFound ExifTool version %s, feature %s is SUPPORTED.",
ver, feature);
} else {
supported = Boolean.FALSE;
log("\t\tFound ExifTool version %s, feature %s is NOT SUPPORTED.",
ver, feature);
}

My solution
if(ver != null){
double verDouble = Double.parseDouble(ver);
double featureVerDouble = Double.parseDouble(feature.version);

            if(verDouble >= featureVerDouble){
                supported = Boolean.TRUE;
                log("\t\tFound ExifTool version %s, feature %s is SUPPORTED.",
                    ver, feature);
            }else {
                supported = Boolean.FALSE;
                log("\t\tFound ExifTool version %s, feature %s is NOT SUPPORTED.",
                        ver, feature);
            }
        } else {
            supported = Boolean.FALSE;
            log("\t\tFound ExifTool version %s, feature %s is NOT SUPPORTED.",
                    ver, feature);
        }

Is this project still alive ?

Hi,
I would like to know if this project is still alive ?
If it is not the case, I would like to know if I could fork the project and, at least, publish v1.1 on maven repository ?

Thank you !

Ability to remove tags?

Is this library able to remove existing tags?

For example, the following command will delete the given tags from the image:
exiftool -n -S -GPSLongitudeRef='' -GPSLatitudeRef='' -GPSImgDirection='' -GPSLatitude='' -GPSAltitude='' -GPSLongitude='' -GPSImgDirectionRef='' -GPSAltitudeRef='' "~/NetBeansProjects/ExifTool/resources/2014-05-10 22.58.52.jpg"

I've been trying to achieve something similar in my application, but I haven't had any luck:
http://pastebin.com/M5GpWPJN
The above code leaves the image untouched, with the original metadata.

If I attempt to set the value to "0" instead of "", a ".jpg_original" file is generated, but the new ".jpg" file still contains the original location data.

Any clue what I'm doing wrong?

Add support for writing metadata

Reminder: Mathias (an exiftool user) that wrote in his own support for writing metadata values found that ExifTool doesn't write UTF8 values correctly unless -codedcharacterset=utf8 is passed to ExifTool.

Will need to do this automatically when this support is added.

No way to pass-through ExifTool raw "no args" output.

A user emailed asking if there was a way to use all this launching infrastructure to get ExifTool's raw no-args output which is a full list of metadata found in an image.

Adding a List getAllMeta() method is a possibility, but a sloppy solution to a shortcoming that the user should be able to extend and solve themself if the base implementation was more flexible.

This also points to the problem of having enum-defined Tags. It makes usage super nice and intuitive, but extension impossible.

Need to think about this more.

missing rotation tag

Could you please expose Rotation in ExifTool.Tag? It is not available as of v1.1

How to get custom tag names?

I need to run exif tool like:

exiftool '-SubSecTimeOriginal' pathToFile

There is no tag for this.

Aside from forking the source, any work around?

Thanks.

Justin

Keywords tag from Lightroom 6 export

I exported jpg's from Lightroom 6 and the "XPKeywords" is not included in the exif data. The "Keywords" tag holds the keywords data. Please add the "Keywords" tag.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.