Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:
Before returning home from vacation, I downloaded the pictures my sister had taken on to my laptop. I just realized her camera has the wrong date so the the meta data in all the pictures is wrong. Thanks to Khisanth, I am pretty sure the module I want to use is Image::ExifTool. I am also fairly certain that the tag I need to modify is one of the following: CreateDate ModifyDate DateTimeOriginal
What I can't figure out is how to use the SetNewValue() correctly such that the WriteInfo() doesn't fail. Does anyone have a complete working example? Admittedly, I have only been RTFMing in between commercials but what I have looks something like this (which I know is wrong):
#!/usr/bin/perl use strict; use warnings; use Image::ExifTool qw(:Public); my $jpg = $ARGV[0] or die "Usage: $0 <file>"; my $tool = Image::ExifTool->new(); $tool->ExtractInfo($jpg); $tool->SetNewValue('Make'); # Deleting this tag magically makes it wor +k my $success = $tool->SetNewValue("DateTimeOriginal", '2008:01:02 03:04 +:05'); if ($success) { $success = $tool->WriteInfo($jpg); print "Update failed", $tool->GetValue('Error'), "\n" if ! $succes +s; } __END__ Update failed[minor] Bad MakerNotes directory pointer for tag 0x203
Update: Added error I am getting.
Update 2: It appears to be a corrupt file (though it views fine) because the same code worked correctly on another picture. Does anyone know how to fix that?
Update 3: I noticed $exifTool->SetNewValue('*'); # delete all non-EXIF tags in TFM. I tried it, and what do you know, it fixed the problem. Of course, I didn't want to delete all the tags so then I restored the original. I then looped over all the tags, deleting each one in turn, and then trying the write. It turns out that 'Make' was the key though I still don't know why. The code above has been modified above to reflect the now working code.
Cheers - L~R
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (Solved) Change "Date Picture Taken" with Image::ExifTool
by b10m (Vicar) on Jul 25, 2008 at 08:16 UTC | |
Re: (Solved) Change "Date Picture Taken" with Image::ExifTool
by polettix (Vicar) on Jul 27, 2008 at 02:48 UTC | |
by Limbic~Region (Chancellor) on Jul 28, 2008 at 13:58 UTC | |
by polettix (Vicar) on Jul 31, 2008 at 09:49 UTC | |
Re: (Solved) Change "Date Picture Taken" with Image::ExifTool
by hbm (Hermit) on Aug 31, 2010 at 14:32 UTC |