God Bless EXIF, And All Who Sail With It


Cashed in my change jar and got a new digital camera a couple weeks ago. The Kodak DX6490! 10x optical zoom! Lenses with Teutonic-sounding name!

I'm all-around happy with it, except for the file-naming rubric it uses. See, I made the grave mistake of architecturing our daughter Olivia's website around the file-naming rubric of my old digital camera (the Olympus D380), which named photos according to the date they were taken. So like a photo taken on September 27 would be named P9270001.jpg. It was highly intuitive, and I'd grown comfortable with that scheme, and I guess either assumed that I'd keep using the Olympus into perpetuity, or that all cameras used some sort of date file-naming scheme. Lo! They do not. The Kodak uses a straight-up numbering scheme&emdash; no dates involved. And no matter how determinedly or repeatedly I read the owner's manual, I can't seem to change that fact.

And baby website aside, I'm pretty anal about shit like this; I gotta have my photos named with a datestamp. So what's a brother to do? I'm wasn't gonna sit there like a chimp and manually rename every photo; that's for goddamn sure. I combed the web high and low for some utility that would batch-rename photos, thinking for sure someone somewhere had come up with something that would rename files based on the datestamp from when they were created. There is one utility called Stamp that fit the bill pretty well, but made file names that were like 40 characters long, plus was uncustomizable.

But I noticed that part of what the Stamp utility does involved EXIF headers (metadata information in the header of digital images), and I thought to myself, "where the hell have I seen 'EXIF' recently?" Duh, the PHP documentation! PHP has a function that can read EXIF headers! Joie de vivre! So now I don't have to dick around with the Windows file-creation datestamp (which changes, you know, when you copy shit from device to device) or any of that type of crap. In the EXIF header of every got-dang digital photo that I take is (among many other things like color range, or whether the flash fired) a to-the-second registration of when that photo was taken, and it's accessible via one adorable little PHP function: read_exif_data().

So after spending about six hours trying to figure out how to get the php_exif.dll happening (oh, it turns out you have to have the php_mbstring.dll enabled too, and that php_mbstring.dll has to load before php_exif.dll, but they couldn't just come right out and tell you that in the PHP documentation, could they? No, that'd be too easy...), I got it running. So over the course of last week, I hacked together a custom PHP script that reads each of these ill-named Kodak photos and copies them to a properly named file named according the following highly intuitive: PYYYYDDMM_hhmmss.jpg. We shall overcome.

Oh yeah, you can have a copy if you need it. It is, how you say, open source?


Up near Rollins Pass last weekend


More Rollins Pass


The Moffat Tunnel. It cuts through the Continental Divide and comes out near Winter Park (for trains only, yo)


On my street on a foggy October morn



COMMENTS


There's a program I found awhile back on snapfiles called Rename4U that works pretty swell
http://www.snapfiles.com/get/rename4u.html
.... you should post these problems BEFORE you find a solution.
Also, it's about time for me to change the quotes at the top (middle?) of my watt page.
I think I'm gonna use part of your watt post. It's a pretty darned swell wrap-up of how I feel about watt too. thanks in advance for not suing me for quoting your spiel.
-b from wmamsf

- Bruce October 08, 2004 11:44

I just re-read my post and realized I used the word "swell" in it twice.

sorry.

- Bruce October 08, 2004 11:48

Hey Bruce- I'm flattered to have you aboard, as I am an admirer of your site and your frequent contributions to the Watt Yahoo listserv thing (or whatever it's called).

By all means, feel free to use that quote for your Watt page. And while I'm on the shameless self-promotion angle, let me point you to a write-up of my pilgrimage to San Pedro in 2001: here. Maybe you'll dig it.

I'll give that Renamer program a whirl--- thanks!

- Yarbolio October 08, 2004 12:04

HIDE