--- exif.module.orig	2009-09-02 16:32:41.070748809 +1000
+++ exif.module.fix	2009-09-03 11:49:00.959749056 +1000
@@ -73,8 +73,7 @@ function exif_nodeapi(&$node, $op, $a3 =
 	
 	switch ($op) {
 		
-		case 'insert':
-		case 'update':
+    case 'presave':
 			$info = content_types($node->type);
 			$fields = $info['fields'];
 
@@ -89,27 +88,12 @@ function exif_nodeapi(&$node, $op, $a3 =
 
 				$fid = db_result(db_query("SELECT fid FROM {files} WHERE filepath = '%s'", $image_path));
 				$file = file_create_path($image_path);
-
-				$data = $exif->readExifTags($file,$ar_exif_fields);
-				
+				$data = _exif_reformat($exif->readExifTags($file,$ar_exif_fields));
 				// prepare data to be stored in CCK
 				$i = 0;
 				foreach ($data as $key => $value) {
 					$field_name = 'field_' . $ar_exif_fields[$i]['section'] . '_' . $key;
 					$tmp = $node->$field_name;
-					
-					$date_array = array('datetimeoriginal','datetime','datetimedigitized');
-					//incase we get a datefield, we need to reformat it to the ISO 8601 standard:
-					//which will look something like 2004-02-12T15:19:21
-					if(in_array($key,$date_array)){
-						$date_time = explode(" ",$value);
-						$date_time[0] = str_replace(":","-",$date_time[0]);
-						if(variable_get('exif_granularity',0) == 1){
-							$date_time[1] = "00:00:00";
-						}
-						$value = implode("T",$date_time);
-						//dsm($value,$key);
-					}
 					$tmp[0]['value'] = $value;
 					
 					$node->$field_name = $tmp;
@@ -172,13 +156,15 @@ function exif_admin_settings(){
 	drupal_add_css(drupal_get_path('module','exif') . '/exif.css');
 	$filepath = drupal_get_path('module','exif') . '/sample.jpg';
 
-	$ar_exif = read_exif_data($filepath,0,true);
+  // Make the key lowercase as CCK field names must be
+  $ar_exif = array_change_key_case(read_exif_data($filepath,0,true), CASE_LOWER);
 
 	$out = '';
 	$rows = array();
 	$help = t('This would be the keyword for your CCK field.');
 	foreach ($ar_exif as $key => $value){
 		if(is_array($value)){
+			$value = _exif_reformat($value);
 			$rows[] = array('data'=>array($key,$help),'class'=>'tag_type');
 			foreach($value as $key2 => $value2){
 				$rows[] = array('data'=>array($key2,check_plain(utf8_encode($value2))));
@@ -191,7 +177,49 @@ function exif_admin_settings(){
 	return $out;
 }
 
+/**
+ * Helper function to reformat fields where required.
+ */
+
+function _exif_reformat($data) {
+  $date_array = array('datetimeoriginal','datetime','datetimedigitized');
+  // Make the key lowercase as CCK field names must be
+  $data = array_change_key_case($data, CASE_LOWER);
+  foreach ($data as $key => &$value){
+    if ($key == 'gpslatitude') {
+      $value = _exif_DMS2D($value, $value['gpslatituderef']);
+    } else if ($key == 'gpslongitude') {
+      $value = _exif_DMS2D($value, $value['gpslongituderef']);
+    } else if (in_array($key, $date_array)){
+      //incase we get a datefield, we need to reformat it to the ISO 8601 standard:
+      //which will look something like 2004-02-12T15:19:21
+      $date_time = explode(" ", $value);
+      $date_time[0] = str_replace(":", "-", $date_time[0]);
+      if (variable_get('exif_granularity', 0) == 1) {
+        $date_time[1] = "00:00:00";
+      }
+      $value = implode("T",$date_time);
+    }
+  }
+  return $data;
+}
+
+/**
+ * Helper function to change GPS co-ords into decimals.
+ */
+function _exif_DMS2D($value, $ref) {
+  $parts = split('/', $value[0]);
+  $dec = $parts[0] / $parts[1];
+
+  $parts = split('/', $value[1]);
+  $dec += ($parts[0] / $parts[1]) / 60;
+
+  $parts = split('/', $value[2]);
+  $dec += ($parts[0] / $parts[1]) / 3600;
 
+  if ($ref == 'S' || $ref == 'W') $dec *= -1;
+  return $dec;
+}
 
 /**
  * Helper function to get the exif class
