Unexpected result of SetNewValue()

Started by HansS713, February 15, 2016, 09:40:15 AM

Previous topic - Next topic

HansS713

I use
($iResult, $sErr) = $poExifTool->SetNewValue($sTagName, $sCorrectTime);
to correct value for 'DateTimeOriginal'. Form the documentation I expect to see $iResult==1 on success, and 0 on error ("Returns ... The number of tags set ..."), but I get 6 (and 7 for 'CreateDate')? So what does the result value really means and what is the correct condition to distinguish success from error?

ExifTool 10.10, Win7-64, perl v5.12.4 (32)

Phil Harvey

Try setting $sTagName = 'EXIF:DateTimeOriginal' to see how many tag were set then.  If you don't specify a group, you are probably setting a lot of other same-named tags.

Running the application with -v3, I see this:

> exiftool a.jpg -datetimeoriginal=now -v3
Writing MIE-Doc:DateTimeOriginal
Writing CanonRaw:DateTimeOriginal if tag exists
Writing Kodak:DateTimeOriginal if tag exists
Writing Reconyx:DateTimeOriginal if tag exists
Writing XMP-exif:DateTimeOriginal if tag exists
Writing ExifIFD:DateTimeOriginal


...which is exactly the 6 you get as a return value.

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

HansS713

But the picture contains Exif information only, both before and after $poExifTool->WriteInfo($sFileName);. So ExifTool has a predefined internal list of all known tags, and the SetNewValue() sets value of all of these tags, but WriteInfo() then (normally) writes only the values of already existing tags, right?

Phil Harvey

Notice that you are calling SetNewValue() without a file name.

SetNewValue() queues up all of the tags that you want to write.

WriteInfo() writes these queued tags to a file.  Some of the tags you queued may not be applicable to the file you are writing, in which case they are not written (eg. MIE tags will not be written to a JPG image, and MakerNote tags may not be created individually).

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