"unsafe to write" & "not writeable"

Started by Aplonis, September 04, 2013, 09:36:04 AM

Previous topic - Next topic

Aplonis

Trying to write a Perl script to fix date tags for images from camera with clock error. But I'm not understanding something because although the script works, the fixing of tags always fails. Below is the the for-loop, somewhat stripped down, wherein the issue lays. The vars $foo and $bar exactly correspond to the format of the original tags, just with corrected date-time (bunch of Perl time math elsewhere in the script to supply this). What do I miscomprehend so that my script runs without error and yet the writing of tags works not?

for my $file (@files) {
    $exif_tool->ExtractInfo($file, \%options);
    my @tag_list = $exif_tool->GetFoundTags('File');
    for (@tag_list) {
        next unless $_ =~ /Date/;
        if ($_ =~ /Access/) {
            $exif_tool->SetNewValue($_, "$foo");
        } else {
            $exif_tool->SetNewValue($_, "$bar");
        }
    }
}

Phil Harvey

Since you're not catching the errors by using SetNewValue in list context, they should go to the console.  You need to add Protected => 1 to the call if you want to write "unsafe" tags.  If you give me more details about a specific tag you are trying to write, and a specific error/warning it gives, I can give you specific more specific.

It seems you may be trying to write FileAccessDate, but this tag is not writable.  See the Extra Tags documentation for more information.

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

Aplonis

Yes, the errors go to console. They are as follows...

Sorry, FileCreateDate is unsafe for writing.
Sorry, FileModifyDate is unsafe for writing.
Sorry, FileAccessDate is not writeable.

And having my options now thus...

%options = (PrintConv => 0, Protected => 1);

...with the change of "Protected => 1" being added, makes no difference.

I was trying to make my time-fix script universalish by submitting it to JPG, JP2 & BMP. Results for all three are equivalent.

Phil Harvey

The Protected => 1 are extra arguments to the SetNewValue() call, not ExifTool options.  Hopefully this should be clear in the documentation.

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

Aplonis

Like so, then....

$exif_tool->SetNewValue($_, $foo, Protected => 1);

...which certainly does away with the errors...

Sorry, FileCreateDate is unsafe for writing.
Sorry, FileModifyDate is unsafe for writing.

...leaving only the error...

Sorry, FileAccessDate is not writeable.

...which is not really at all important.

Thank you. I must have been dense or too hasty in reading the documentation, which I am sure must be fine.