Order of execution regarding -stay_open

Started by frankitox1, September 05, 2024, 03:12:43 PM

Previous topic - Next topic

frankitox1

Hello!

I'm using the -stay_open feature. I'd like to know if there's any guarantee in the response order. So that if I send as input two execute commands: something like -execute1\n ... file1.jpg\n and execute2\n ... file2.jpg. Can I be sure I'll get back {ready1} before {ready2} in the output?

Totally unrelated, but the password recovery feature of the forum doesn't seem to work (I'm not getting the password recovery email)

greybeard


FrankB

What Greybeard asks is relevant. Suppose you send the next command only when the previous has completed, then there will be no problem.
But even if you should send the next -execute before the output of the previous has completed, then there will not be a problem. I have experience in calling ExifTool from ExifToolGui and have never seen that happening.

I would however beware of the following. Suppose your -execute makes ExifTool print errors/warnings to STDERR. How do you correlate the lines in STDERR to the lines in STDOUT?
What I use in ExifToolGui (Advised by Phil) is
-echo4 CRLF {readyxx} CRLF (Where xx is the same nbr as -execute)
The output of the command will print the same {readxx} on STDOUT and STDERR. That's how you know.

See C++ interface: https://exiftool.org/cpp_exiftool/
or ExifToolGui: https://github.com/FrankBijnen/ExifToolGui/blob/main/Source/ExifTool.pas

frankitox1

Hi guys. I don't completely understand. I'm starting exiftool with the following command

exiftool -stay_open True -@ -

Then sending as input stuff like this (split by line so it's more readable)

-overwrite_original
-ignoreMinorErrors
-xmp:all=
-iptc:Credit=
-iptc:By-line=
-iptc:EditStatus=
-Artist=
-Rating=1
coco.jpg
-execute1

After writing to the process input this long line I force flush as suggested in the man page. So my original question was, it's possible that I get in the process output `{ready2}` before `{ready1}`? I'm asking because maybe exiftool uses more than one thread and processes the second image first. I'm assuming there's no error. Although thanks for the clarification FrankB! I gotta explore how to use that `-echo4` flag.

StarGeek

Quote from: frankitox1 on September 05, 2024, 05:37:12 PMThen sending as input stuff like this (split by line so it's more readable)

Just pointing out, -@ (Argfile) option requires that each parameter is on a separate line. You cannot combine multiple arguments in a single line in this case. See FAQ #29, "My options don't work in a -@ ARGFILE".

QuoteI'm asking because maybe exiftool uses more than one thread and processes the second image first.

Going all the way back to 2009
Quote from: Archive on May 12, 2010, 08:54:39 AM[Originally posted by exiftool on 2009-08-18 12:03:52-07]

ExifTool is not multi-threaded.  If you want to take advantage
of multiple processors, you must launch multiple copies of
exiftool.

- Phil

Photool's IMatch uses exiftool in the way, launching four separate instances of exiftool in the background.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

greybeard

Its still not clear to me exactly what you are doing.

How are submitting the commands? Are they from a program or using something like a command line terminal?

How are you force flushing?

And how are you then submitting the commands that end in execute2?


frankitox1

Hey guys!

Thanks for the clarification about the number of threads, that just makes my life easier.

greybeard, I'm not sure how granular you want me to be. I'm using Clojure to start exiftool, I think behind the curtain Java's Runtime.exec gets called and I end up with 3 streams, one for pipping my input the other two for output and errors. To flush I'm using Clojure's flush function.

I tried using `-echo3` and `-echo4` but it doesn't seem to work with `-stay_open`? Tried something like

-overwrite_original\n-ignoreMinorErrors\n-xmp:all=\n-iptc:Headline=A little galler\n-iptc:DateCreated=20240519\n-iptc:Province-State=Chubut Province\n-iptc:Sub-location=Chubut\n-iptc:City=-\n-iptc:Credit=Creator\n-iptc:By-line=Alice\n-iptc:EditStatus=\n-iptc:Country-PrimaryLocationName=Argentina\n-iptc:Caption-Abstract=Coco\n-ImageDescription=Mr T\n-Description=Mr T\n-xmp:UsageTerms=All rights reserved\n-iptc:CopyrightNotice=Alice\n-iptc:Keywords=vertical\n-Artist=Alice\n-Rating=2\n/tmp/coco.jpg\n-echo3 myecho3\n-echo4 myecho4\n-execute2485\n

But I'm getting some invalid tag name errors

frankitox1

I'll consider this issue solved, mostly because the clarification about the number of threads. I assume it's a bug in my code, and some faulty synchronization code.

FrankB

Despite you regard this issue as closed, I want to point out that the -echo4 myecho4 should be on 2 lines.

ExifToolGui has the option to create CMD or PS files from the commands it issues. Have a look at this sample.
(Remove the DEL at the end, if you want to keep the ARGS file)

@echo off
chcp 65001
set ARGS="%TEMP%\exiftool.args"
(
echo #### Generated by ExifToolGui #####
echo -echo4
echo {ready13}
echo -CHARSET
echo FILENAME=UTF8
echo -CHARSET
echo UTF8
echo -v0
echo -overwrite_original
echo -sep
echo *
echo -c
echo %%.6f°
echo -API
echo WindowsWideFile=1
echo -s3
echo -f
echo -GUI-SEP
echo -exif:Make
echo -exif:Model
echo -exif:LensModel
echo -exif:ExposureTime
echo -exif:FNumber
echo -exif:ISO
echo -exif:FocalLength
echo -exif:Flash
echo -exif:Orientation
echo -exif:DateTimeOriginal
echo -exif:CreateDate
echo -exif:Artist
echo -exif:Copyright
echo -exif:Software
echo -Gps:GPSLatitude
echo -GUI-SEP
echo -xmp-dc:Type
echo -xmp-xmp:Rating
echo -xmp-iptcExt:Event
echo -xmp:PersonInImage
echo -xmp-dc:Subject
echo -xmp:LocationShownCountryName
echo -xmp:LocationShownProvinceState
echo -xmp:LocationShownCity
echo -xmp:LocationShownSublocation
echo _IGP0001.jpg
echo -execute13
) > %ARGS%
exiftool  -@ %ARGS%
del %ARGS%
pause


StarGeek

@FrankB is correct. You example shows this (replacing \n with new lines)
-echo3 myecho3
-echo4 myecho4

And should be
-echo3
myecho3
-echo4
myecho4

See FAQ #29, "My options don't work in a -@ ARGFILE".
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

frankitox1

Nice! Thank you guys. This pretty useful, specially for the error logs!