Saturday, July 12, 2008

Fixing EXIF Date/Time Stamp in Photos

[UPDATE] I've uploaded source code to the SVN repository on SourceForge.net that is capable of changing the date and time stamps in JPEG EXIF images. The software is barebones, but feel free to contribute should you so desire. Eventually, a GUI would be nice. This project depends on the Exiv2 library and on Expat. You will need to link to Exiv2 and have its header files in your include path, and will need to have the Expat DLLs either installed in a globally accessable path or in the program executable directory. This software comes with no warrantee, so please use it at your own discretion and MAKE BACKUPS OF YOUR PHOTOS prior to running the software!

=====================================

It's been bothering me for a few years now -- my girlfriend's camera has an incorrect date/time setting. As a result, any photos that I import from her camera get sorted incorrectly by date by programs like Picasa or Windows Explorer (view -> details shows "Date Picture Taken").


The date and time data are not stored concurrently with the file access/create/modify data, but are instead stored inside the JPEG file, in the metadata portion. This portion is known as EXIF data, and provides a space for your camera to record all sorts of good information about the photo, such as resolution, shutter speed, F-stop, flash settings, and more. However, this data proves to be a formidable data structure to tackle independently. Luckily for me, I found a lovely library known as Exiv2. Exiv2 provides a cross-platform library for reading and writing the EXIF and metadata inside JPEG files. Using the library, it is possible to add, modify, or remove this metadata.

Some very useful scenarios for this include
  • setting the date of a scanned photo
  • correcting the date of photos from a digital camera that was not configured properly
  • storing other, extra information about a photo inside the photo itself.
For my scenario, I will be using the library to systematically correct the 1,000+ photos taken by my girlfriend's Pentax Optio S40 camera, whose date is off by 7 days, 21 hours, and 56 minutes. I'll start off by opening a JPEG, checking to see if it was captured using that model of camera, then adjusting 3 different timestamp fields: "Exif.Image.DateTimeOriginal", "Exif.Photo.DateTime", and "Exif.Photo.DateTimeDigitized".

I'll be posting my source code to SourceForge as soon as the project is approved. Check back for more info.

[UPDATE]: After I spent time successfully writing software to perform this action, it appears as if my efforts are futile. Every time I turn on the Pentax Optio S40, the time changes by 1 hour and 20 minutes. By turning on and off the camera repeatedly, I find this to be fairly consistent.

I turned the camera on/off within seconds, and noticed the time change:
  • 7/3/2008 10:02pm
  • 7/3/2008 8:42pm
  • 7/3/2008 7:22pm
  • 7/3/2008 6:02pm
It looks to me like a systematic software bug. The camera has version 1.0 of the firmware (found by holding down the Menu button at power-on). I have found no path for upgrading firmware for the Optio S40 via the Pentax website either.

I still plan on posting the source code to my application on SourceForge, pending approval.

Wednesday, July 2, 2008

Snooze Button Addiction

I don't know too many people who can top my inexplicable ability to repeatedly torture myself in the wee hours of the morning. At the peak of my snooze button habit, I would tell myself the night before that I would "definitely wake up" at 6am. In reality, I would wake up at 9:30AM or sometimes even later, while reprogramming the alarm clock in 6-15 minute intervals.

"Reprogramming?" That's right. I don't have a snooze button at all. I disabled it years ago because I recognized my problem. However, I quickly learned that pushing only a few more buttons not only allowed me to snooze once again, but would also allow me to customize how long I snoozed for.

I've tried moving the alarm clock to the other side of the room without luck. I've tried moving the alarm clock to a different room; still no luck. I've tried setting multiple alarms, setting the coffee maker to go off at a given time, but still, to no avail.

It's worth noting that I do not have a problem waking up when people are depending on me to be somewhere. I only exhibit this behavior when I have the option of sleeping late without consequence. I've behaved this way since college, at least, and have become frustrated with myself for not having any free time in the afternoon. Thus, I have found what I think is a path toward breaking my habit.

Throw away the alarm clock. Don't use it. Don't set it. I obviously can't handle the tremendous power of the alarm clock when I have nothing scheduled in the morning. I know other people have this problem as well, so hopefully I'll break through some barriers here.

I have not used my alarm clock all this week. While I woke up later than I would ideally like to wake up, I felt completely rested in the morning. Today, I felt myself drift in and out of sleep slightly before 6am, indicating that I was at an ideal point in my sleep cycle to wake up. I didn't wake up because I decided not to get out of bed, but at least this gives me a glimpse of what it's like to use a natural, biological clock instead of a blaring, disturbing, and obnoxious electronic device.

I will continue without an alarm clock until my sleeping habits improve, except for mornings in which meetings or appointments are scheduled. After all, if the source of my problem is a habit entwined with that cursed device, I must start by eliminating it from the equation.