Monday, May 14, 2007

EXIF Writing in Python

How much does it suck to transfer a few hundred photos from your camera, only to afterwards notice the date on the camera was wrong? So, here I go looking for an EXIF batch updating program, and the pickings are much slimmer than I would expect. Of course, writing my own seems like a pretty viable option and the EXIF.py module would be grand to apply here, save for one problem: It was written in 2002 and it still doesn't write back to the image.

What's a dad with hundreds of family photos to do? Fix it. Talked with someone else interested in this and came up with three options to move forward.
  1. Replace the entire module with a ctypes wrapping over the libexif library.
  2. Jam EXIF writing into the existing module by invoking the exif command-line utility.
  3. Reverse engineer the EXIF format from the modules parsing functions and properly implement writing into the library.
Cross-platform support is great, but I'm having a crappy time trying to cross-compile the exif utility to windows, I can't find binaries for it, and that is some sand in my pants. Then again, I really wouldn't use it on Windows, so I can defer the search for the command line utility on Windows until later. For ease of implementation, this will probably be the route taken. I'll post the results here later, but I probably won't send patches to the maintainer, because the methods I'll use won't match well there. The current library isn't really designed well for this, so I think a redesign would be needed to do it in a really good way.

If anyone knows that this is futile and a solution already exists, please let me know.


4 comments:

Cat said...

Take a look at this:

http://www.sno.phy.queensu.ca/~phil/exiftool/

It's not in Python but it might be just good enough to get the job done.

Michael Urman said...

Did you try the cheeseshop? Pexif 0.8 looks likely to be useful.

Chris Lambacher said...

Here are some options that work on Linux, not sure about cross platform.

Exiv2 claims to have been born because of the exact problem you want to solve.
http://www.exiv2.org/

I have used jhead before to extract info, but it also claims to be able to "relative adjust" timestamps.
http://www.sentex.net/~mwandel/jhead/

Anonymous said...

Hmm, you sure its that good?

Ibiza

I write here about programming, how to program better, things I think are neat and are related to programming. I might write other things at my personal website.

I am happily employed by the excellent Caktus Group, located in beautiful and friendly Carrboro, NC, where I work with Python, Django, and Javascript.

Blog Archive