In order to view the correct ISO speed from my Canon cameras and extract the GPS data in the EXIF header I had to modify the default EXIF parser that comes with MG2.
UPDATE – I have updated the script to work better with the Canon Rebel XT digital camera. Read more about the updates here.
There is a tutorial on the MG2 site for upgrading the EXIF parser to use Exifer to help extract camera specific settings. Unfortunately, when I tried it, Exifer gave me some strange results with GPS data like the following that made it hard to parse.
[GPS] => Array ( [NumTags] => 7 [Version] => 220.127.116.11 [Latitude Reference] => N)A [Latitude] => 22.878641666667 [Longitude Reference] => W [Longitude] => 109.89785277778 [Altitude Reference] => 00fc0000 [Altitude] => 1 )
I did, however, use this tutorial to help guide my update to a different EXIF parsing solution.
PHP has an EXIF parsing library available to it. Some hosts do not allow access to this library by default, which is why there is the need for third party EXIF parsers. Fortunately, my hosting provider does enable the EXIF parsing library.
This page describes how I used the default PHP Exif functions to extract the Canon camera specific information as well as the GPS data and show it in my MG2 gallery. The basic structure of the EXIF structure in the code is retained from the default installation so the MG2 skins do not need to be changed.
Download the files needed from here
Copy the new files
canon_php_exif.php to the “includes” folder. See here for more information on Canon Makernotes.
At line 287 (in version MG2 0.5.1) replace this line…
with this line…
Just below that also replace this line…
$exif_data['ExposureTime'] = $mg2->dec2frac($exif_data['ExposureTime']) . $mg2->lang['seconds'];
with this line…
$exif_data['ExposureTime'] = $exif_data['ExposureTime'] . $mg2->lang['seconds'];
since the new parser prefers to keep the data in fraction form there was no point in converting it and then converting it back here.
I did make some changes to the default “rounded” MG2 skin. This was mostly for the GPS data, which was my original intent with this project. I changed
viewimage_exif.php with the following changes.
I added a function to construct a google maps URL from the GPS data.
I replaced this…
because the ‘DateTime’ is the last time the file was edited, not when the photo was taken.
I added the following two lines in the GPS data table.
See my gallery for an example running with these changes. To see where the photos were taken, view the Exif info and select “View location in Google Maps”.
For more information on GeoTagging Photos to embed the Exif information see my GeoTagging Photos page.
This script has been tested with files from the Canon S400 and Canon Digital Rebel XT. If you have files from other Canon cameras that do not work I would like to see them. Please leave a comment.
This script can easily be extended to support other cameras or read more than just the ISO data. Please feel free to fix or improve it and send me updates.