View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

iPhoto album XML reader

Home   How To   Code Pool   Public Library   Theory   Events
I just had an absolute gas this afternoon getting SuperCollider to extract information from my iPhoto library!

In the past I've exported photos as web pages, but it's really hard to make changes to all the pages at one time. So I thought, why not read the XML, use it to populate a couple of database tables, and write a quick and dirty php script for display?

Jens Gulden's DOMDocument classes made it easy to read the XML – it took some experimentation to find the right data, but I had the basic logic worked out in a bit more than an hour. It wasn't too hard to put a GUI wizard on top to validate input.

For fun, I made the GUI compatible with SwingOSC, but then realized that the point is moot because only Mac users have iPhoto...

Even if you don't have iPhoto, the code is an interesting example of how to use the XML reader. Also, the flow of control structure is worth a look if you were wondering how to construct interfaces that let you click through stages.

And of course, maybe someone will find it useful for its intended purpose.



You must have Jens Gulden's DOMDocument classes, XML parsing and formatting.


When you run this script, you will be presented with a file open dialog. Navigate to the location of the iPhoto AlbumData.xml file, which normally should be located at ~/Pictures/iPhoto Library/AlbumData.xml.

This file can be big, so wait a few seconds for it to read!

The next dialog is a list of all the photo albums in the library. Choose the one whose data you want to read.

Finally, you see a list of the types of data you can extract. Click the button for each one you want – your selections are in green.

After processing, you will be prompted for a location to save the data. It will be saved as a SuperCollider archive – open it later with Object.readArchive(pathname). The result is an ordered List, where each item is a dictionary holding one key/value pair for each type of data you requested. If a key was unpopulated in the library, it will be missing from the resulting dictionary, i.e., list[index][key] == nil.

By dewdrop_world - H. James Harkins -

Link to this Page