Hello Phil,
when launching ExifTool (here: ExifTool.exe v8.43) with the "-stay_open" option and writing some "list" commands to the current *ARGFILE*, then each line of the output will be delimited by <CR><LF> - as expected when reading ExifTool's output from StdOut on a Windows system (here: Win XP Pro, SP3). If the option "-b" (or "-binary") will be added to the *ARGFILE*, each line from StdOut will be delimited only by a single <LF> from that moment.
Example:
1. Prepare an *ARGFILE* <ArgFile.txt> with the following content:
#~~~ Step 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-EXIF:All
Image.jpg
-execute
#~~~ Step 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-b
-IPTC:SupplementalCategories
Image.jpg
-execute
#~~~ Step 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-EXIF:All
Image.jpg
-execute
#~~~ Step 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-stay_open
False
2. Start ExifTool:
ExifTool -stay_open True -@ ArgFile.txt >ExifToolStdOut.txt
3. Check <ExifToolStdOut.txt>:
Output from step 1 will be delimited by <CR><LF>.
Output from step 3 (and step 2) will be delimited by <LF>.
My application splits ExifTool's output on <CR><LF> and it fails, after it has once passed the "-b" option to ExifTool. Not that serious, I will fix my application according to this finding. However, would it be possible, to have a consistent usage of line endings with ExifTool in a future version?
Thank you!
I need to do some work to solve this. I set binmode on stdout when the -b option is used (for obvious reasons). Your problem is that stdout stays in binmode for subsequent -execute commands. My problem is I don't know how to reset binmode on stdout once it has been applied. I will look into this.
- Phil
I tried to dup STDOUT, but restoring it later didn't reset the binmode:
open SAVEOUT, '>&STDOUT'; # save STDOUT
binmode(STDOUT); # set binmode
# --- print binary stuff here ---
open STDOUT, '>&SAVEOUT'; # restore STDOUT
# --- print more stuff here, but unfortunately binmode is still in effect
The only solution I have found so far is a bit messy, and looks something like this:
if ($] >= 5.006 and ($^O eq 'MSWin32' or $^O eq 'os2' or $^O eq 'dos'))
{
binmode(STDOUT, ':crlf');
}
But this only works with Perl 5.6 or later, and I'm sure there are other systems I don't know about that use CR/LF.
However, I think this should solve the problem for your specific system and Perl version (the ExifTool windows executable ships with Perl 5.8.7), so I will implement this in the next release (ExifTool 8.44) unless I come up with a better alternative.
- Phil