Extract EXIF data using PHP to display GPS-tagged Images in Google Maps

While cycling around the city this past weekend with my girlfriend I shot a couple quick photos with my iPhone to play with some of the encoded EXIF/GPS data for an upcoming project I am working on. After creating some quick thumbnails, I built the following Google Maps prototype to display the images where I photographed them extracting the GPS data with a PHP script I have running on the server.

In the process of building this simple example I came across a strange phenomenon where the GPS data wasn’t being preserved if the original iPhone image was altered in any way. This was happening whenever I saved an edited version of the image in Photoshop CS4 including the creation of a thumbail. Even with the preserve metadata flag selected when saving for web.