ExifTool Forum

ExifTool => Developers => Topic started by: dc@eicx.com on January 03, 2021, 02:07:48 PM

Title: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: dc@eicx.com on January 03, 2021, 02:07:48 PM
I have been using Exiftool for quite a while.  I have been calling it in what I have always considered a kludgy way.

Using PowerBasic I call it this way:  SHELL   (ENVIRON$("COMSPEC") + " /C exiftool.exe " + EXIF_FILE + " > EXIF_OUTPUT.TXT", 0)

This works but is very slow.

I see there is no DLL so I am assuming that calling the entire program is the only way to interface to it?

Could someone explain what the preferred way to use exiftool as a resource for my program?

Does exiftool have to be present on the computer or can the functionality be compiled into my program? 
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: StarGeek on January 03, 2021, 03:33:59 PM
I'm guessing you're calling exiftool for each and every file?  That's Common Mistake #3 (https://exiftool.org/mistakes.html#M3).

You don't mention what you're calling from.  Is it a programming language like Python?  If so, look to see if there's a exiftool wrapper such as pyExiftool (http://smarnach.github.io/pyexiftool/) or C++ Interface (https://exiftool.org/cpp_exiftool/) for that language (see here (https://exiftool.org/#related_prog)).

Otherwise, what you'll want to do is use the -stay_open option (https://exiftool.org/exiftool_pod.html#stay_open-FLAG), -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE), and the -execute option (https://exiftool.org/exiftool_pod.html#execute-NUM) too keep exiftool running until you shut it down.
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: dc@eicx.com on January 04, 2021, 01:58:25 PM
OK - I am starting to see what you are saying.

You can have an interactive conversation with exiftool.

Does the tag data still get written to a file or can it be streamed, pipped to my control program?

I am using the PowerBasic compiler - I will post code once I get it working...

Thanks!
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: Phil Harvey on January 04, 2021, 02:03:51 PM
Typically the exiftool output would be piped directly to your control program.  There should be examples of this here (https://exiftool.org/#related_prog).

- Phil
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: StarGeek on January 04, 2021, 02:04:32 PM
There's some VB code examples if you search here in the forum.  I don't know how that compares to Powerbasic, though.  I'm not familiar with either.

I can't really answer your other question as I've never used that option.  But I'm sure something can be done.  Imatch (https://www.photools.com/) for example, runs about four instances of exiftool while it's running.

Here's an example (https://exiftool.org/vb_sample.html)
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: dc@eicx.com on January 04, 2021, 02:58:18 PM
Let me ask the question a different way.

Assume I am running exeftool in a "dos box / console" in windows

I am trying to have an interactive conversation with exiftool in the console window.

I ask because I want to be sure my exeftool commands are correct before I go to piping in and out.

Steps taken:

Open command window and change to directory with exeftool and some test image files.

I Type > exiftool test.jpg -stay_open 1 -

Then I get what I assume is an exiftool "ready for input"  ======== -

After that no mater what I do nothing happens...
I tried -execute,

My question is how would I do the followning

Start exiftool with no file, just tell it to "get ready to receive commands"

Feed it a file name of an image.
Get back the image data

Feed it a file name of an image.
Get back the image data

etc...

Tell exiftool to close.

Can I do that by hand in the console and then the same thing using pipes?
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: Phil Harvey on January 04, 2021, 03:09:47 PM
You forgot the -@

Try this:

exiftool -stay_open 1 -@ -

- Phil
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: dc@eicx.com on January 04, 2021, 03:12:48 PM
Thanks!! That did it.
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: dc@eicx.com on January 04, 2021, 03:47:10 PM

Looks like in dos box you have to type -stay_open CRLF 0 to end...
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: Phil Harvey on January 04, 2021, 07:46:27 PM
Yes.  In fact, in any usage.  This is outlined in the step-by-step instructions in the app documentation for the -stay_open option.

- Phil
Title: Re: Could someone explain the "Big Picture" for using exiftool in an application.
Post by: dc@eicx.com on January 05, 2021, 01:19:34 PM
Thank you very much for the help!!

Now I am off to work out my side of things...