365 Project: Using PHP to create an automaticlly generating gallery based on EXIF, IPTC, and XMP metadata.

I was recently invited to join a local photography collective. One of the expected contributions is a ’365 Project’ from each of the eight or so photographers. Eventually, these photographs will be aggregated into one place. (For those of you who aren’t familar with the project, it’s pretty much what it sounds like: make and post one image per day for one year. 365 days, 365 photos.)

While I make photographs almost everyday, having such a definite schedule seems a little scary. Good scary, though. I started thinking about ways to make it easier, and I realized that creating a clever way to display them would make the post-processing more painless. Painless is good. After thinking for a day or so, I realized that I could probably get PHP to read the EXIF from the camera. EXIF data is recorded the moment the image is written to the CF card. It has things like camera make and model, shutter speed, aperture, ISO, focal length, etc. It also has the exact time the image was made. I thought it’d be cool to include all of these things in the gallery.

I started Googling for PHP and EXIF stuff, and sure enough, PHP has a built in function called exif_read_data to do it. How about that! After reading a bit and following some examples, I had it mostly working. The beauty of this system is how freakin’ easy it is to use. Each day, all I need to do it put a sized JPEG in the directory. No special naming, nothing. The page automatically pulls all the information from the JPEG headers, sorts them in reverse by capture time, and prints it out. Pretty cool.

I also wanted to be able to read the ‘Description’ field added from Adobe Bridge/Photoshop and put it below the image as a caption. Unfortunately, this information isn’t stored in the EXIF section of the JPEG headers. A little more Googling turned up a way to read IPTC content, but it actually isn’t stored there either. More investigation turned up that what I wanted was actually in an XMP header created by Adobe Bridge/Photoshop. I found a function to do some matching in this XMP header, but it wasn’t quite what I needed.

After drilling down into the XMP structure, I came up with a very simple and not very pretty way to get the description field out. The script checks all three places (EXIF, IPTC, XMP) and shows the caption if it’s there.

Who knew there were so many headers in image files?

http://www.ivarvong.com/365
Here’s the PHP code on PasteBin: http://pastebin.com/f5572551a

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to 365 Project: Using PHP to create an automaticlly generating gallery based on EXIF, IPTC, and XMP metadata.

  1. Roger Bong says:

    Great work and glad you’re in with us!

Leave a Reply

Your email address will not be published. Required fields are marked *

Connect with Facebook

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>