The Web Sucks | April 18, 2005 11:48 AM | Comments (3)

I just got a Flickr Pro account and I've been uploading my digital photos. My Treo 650 doesn't stick EXIF data in the JPEG images it captures, so Flickr assumes that the "posted on" date is the same as the "taken on" date.

The file attributes of the Photo_MMDDYY_NNN.jpg files accurately reflect what time the picture was taken, so here's a short Perl script to embed that data into the EXIF part of each file:

#!/usr/local/bin/perl -w                                                        

use strict;
use POSIX ();

foreach my $file (@ARGV) {
    my $mtime = (stat($file))[9];
    my $ts = POSIX::strftime("%Y:%m:%d %T", localtime($mtime));

    system("exiftool", "-P", "-DateTimeOriginal=$ts", 
           "-Make=PALMONE", "-Model=Treo 650", $file);
}

exit(0);

I tried using the jhead tool to do this, but it won't create an EXIF header if one doesn't already exist. The Image::ExifTool perl module had the functionality I needed.

There's certainly a way to use the Image::ExifTool perl module directly, but it was easier to just shellout to the command-line utility.

Archives
Comments

'Twould be cool add in the Camera Model Name (Treo 650) as well. I'm not sure if any other EXIM data applies to the meager camera in the 650.

Posted by Jeff Boulter at April 18, 2005 01:53 PM

Tweaked the script appropriately. Unfortunately, you can't infer anything else (i.e exposure, aperture, or focal length) from the .jpg filee.

Posted by Michael J. Radwin at April 19, 2005 01:19 PM

I've often lamented the fact that my Treo 600 does not embed EXIF headers (mostly for the timestamp). But I don't even get a file mod time to base it off when I use the Treo's "share" functionality to upload the photo directly from the phone, which is where I really want the timestamp to be available. Actually, I guess that part (no useful file mod time) is probably not the Treo's fault but that of the lame SprintPCS photo-hosting service that "share" is uploading to.

Posted by neilfred at April 29, 2005 12:53 PM

Copyright © 2007 Michael J. Radwin. Some rights reserved.