Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
All,
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


In reply to (Solved) Change "Date Picture Taken" with Image::ExifTool by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2024-03-28 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found