ExifTool termination status

Started by marchyman, December 29, 2018, 01:27:24 PM

Previous topic - Next topic

marchyman

I'm calling ExifTool from within a Mac application written in Swift.   The generated ExifTool command line has these options

-q -m -overwrite_original_in_place -GPSLatitude=<lat> -GPSLatitudeRef=<ref> -GPSLongitude=<lon> -GPSLongitudeRef=<ref> -AllDates=<timestame> -GPSStatus= path/to/image

I launch ExifTool and then wait until exit.  After exit I retrieve the terminationStatus.

A subset of my users are reporting that ExifTool (or macOS) is returning a status of 1 indicating some kind of error.  However, when image metadata is examined all of the updated fields are correct.  Everything looks correct.   Of course I have not been able to reproduce the problem on my machines.  This happened in version 11.10.   After updating to version 11.22 one user reported the problem happening less often.  Perhaps that is coincidence.

Has anyone else seen something similar?  I've looked through the code and don't see anything obvious as to why ExifTool would return 1 but still update the image (but I'm not a Perl guy so could have easily missed something).  And it could be a macOS or Swift library issue.

Phil Harvey

In an error occurred (exit status 1), then at least one of the files shouldn't have been updated.  There should be an error message that you could check to see the exact reason.  Are you capturing stderr?

- 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 ($).

marchyman

The handful of users that reported the issue say that all of their images were updated.  I try not to argue with my users so I've not pushed back much.   stderr has been going to /dev/null.  I'll have to change that and get one of my users that can reproduce the error use the code and send me the results.

marchyman

Problem resolved.

The issue had nothing to do with exiftool, but with the way the command line was built to invoke exiftool.  In some cases the command line contained empty arguments.  Example:

"-q" "-m" "-overwrite_original_in_place" "-GPSLatitude=37.515013333333336" "-GPSLatitudeRef=N" "-GPSLongitude=122.33953333333334" "-GPSLongitudeRef=W" "" "" "-AllDates=2018:06:07 16:26:23" "-GPSStatus=" "/Users/marc/Pictures/IMG_3565.JPG"


The two empty arguments were treated as file names that did not exist -- Error: File not found - -- causing an error return.  The actual image was updated without error.

Phil Harvey

#4
Ah.  Interesting.  Thanks for letting me know.  This is the first time I remember this happening.  I'll check for this and add a more meaningful error to make it more obvious if anyone else has this problem.  So with future versions you'll get this:

Error: Zero-length file name - ""

- Phil

Edit: Would it make life easier for you if I added a no-operation option, like -nop maybe?
...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 ($).