Reading the documentation for this module, it looked like it was going to extract geo (latitude, longitude) from images, but I couldn't get it to work. Looking into the code and comparing the data actually extracted from the images, it turns out the location information coming from the images is in degrees, minutes, seconds format delivered as an array. The helper function _exif_reformat_DMS2D is dealing with the proper conversion of this data.
The problem is that the _reformat method never calls _exif_reformat_DMS2D for latitude, longitude because the 1st condition is for is_array($value) which is true for latitude, longitude, so it never branches into the code where _exif_reformat_DMS2D is called.
function _reformat($data) {
$date_array = array('datetimeoriginal', 'datetime', 'datetimedigitized');
// Make the key lowercase as field names must be.
$data = array_change_key_case($data, CASE_LOWER);
foreach ($data as $key => &$value) {
if ( is_array($value) ) {
$value = array_change_key_case($value, CASE_LOWER);
foreach ($value as $innerkey => $innervalue) {
if (!drupal_validate_utf8($innervalue)) {
$innervalue=utf8_encode($innervalue);
}
$innervalue=check_plain($innervalue);
}
} else {
if ($key=='usercomment' && $this->startswith($value,'UNICODE')) {
$value=substr($value,8);
}
if ($key=='title' || $key=='comment' || $key=='usercomment' || $key=='comments' || $key=='author' || $key=='subject') {
$value=$this->_exif_reencode_to_utf8($value);
} elseif ($key == 'gpslatitude') {
$value = $this->_exif_reformat_DMS2D($value, $data['gpslatituderef']);
}
elseif ($key == 'gpslongitude') {
$value = $this->_exif_reformat_DMS2D($value, $data['gpslongituderef']);
}
elseif (in_array($key, $date_array)) {
// In case 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);
} else {
if (!drupal_validate_utf8($value)) {
$value=utf8_encode($value);
}
}
}
}
return $data;
}
If fixed this by explicitly ignoring the longitude and latitude fields in the first condition, so they are actually handled further down in the code
if (!preg_match('/(longi|lati)tude$/',$key) && is_array($value))
Comments
Comment #1
jphautin commentedComment #2
jphautin commentedpatch apply on dev version
Comment #3
jphautin commentedSorry, I have to remove the patch on head as this make some regression. Moreover, I think this issue is already fix on head version.
Please, take a look at the 7.x-1.x-dev version to ensure you no more have the issue.