Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (4)
    As of 2020-10-31 08:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favourite web site is:












      Results (287 votes). Check out past polls.

      Notices?