Hi,

I just tried the development version of the exif module to use the GPS data written in the Exif informations of the image I have uploaded. It is possible to get any information but the GPS longitude and latitude. These fields are empty after I have created a new node.

Before you ask the question: yes, the image has GPS coordinates :) Here is an exerpt of the XMP sidecar file:

xmlns:exif='http://ns.adobe.com/exif/1.0/'>
80053/12102
1
0
2007-09-24T13:54:45
0221
0
2
1/400
10/1
0100
560/1
2
151831/49
133209/43
1987526/2085
0
19,14.340000S
23,21.400200E
2.2.0.0


400


5
800
532
0
4563/529
0

Comments

travel-pictures’s picture

Great... Drupal has stripped the XMP-Sidecar-Informations... here they are again:

 <rdf:Description rdf:about=''
  xmlns:exif='http://ns.adobe.com/exif/1.0/'>
  <exif:ApertureValue>80053/12102</exif:ApertureValue>
  <exif:ColorSpace>1</exif:ColorSpace>
  <exif:CustomRendered>0</exif:CustomRendered>
  <exif:DateTimeOriginal>2007-09-24T13:54:45</exif:DateTimeOriginal>
  <exif:ExifVersion>0221</exif:ExifVersion>
  <exif:ExposureMode>0</exif:ExposureMode>
  <exif:ExposureProgram>2</exif:ExposureProgram>
  <exif:ExposureTime>1/400</exif:ExposureTime>
  <exif:FNumber>10/1</exif:FNumber>
  <exif:FlashpixVersion>0100</exif:FlashpixVersion>
  <exif:FocalLength>560/1</exif:FocalLength>
  <exif:FocalPlaneResolutionUnit>2</exif:FocalPlaneResolutionUnit>
  <exif:FocalPlaneXResolution>151831/49</exif:FocalPlaneXResolution>
  <exif:FocalPlaneYResolution>133209/43</exif:FocalPlaneYResolution>
  <exif:GPSAltitude>1987526/2085</exif:GPSAltitude>
  <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
  <exif:GPSLatitude>19,14.340000S</exif:GPSLatitude>
  <exif:GPSLongitude>23,21.400200E</exif:GPSLongitude>
  <exif:GPSVersionID>2.2.0.0</exif:GPSVersionID>
  <exif:ISOSpeedRatings>
   <rdf:Seq>
    <rdf:li>400</rdf:li>
   </rdf:Seq>
  </exif:ISOSpeedRatings>
  <exif:MeteringMode>5</exif:MeteringMode>
  <exif:PixelXDimension>800</exif:PixelXDimension>
  <exif:PixelYDimension>532</exif:PixelYDimension>
  <exif:SceneCaptureType>0</exif:SceneCaptureType>
  <exif:ShutterSpeedValue>4563/529</exif:ShutterSpeedValue>
  <exif:WhiteBalance>0</exif:WhiteBalance>
 </rdf:Description>
pomliane’s picture

Priority: Normal » Critical

Hi,
It seems gpslongitude and gpslatitude are left unfilled because of an issue with the type of data : a string is expected but an Array is passed.
Same issue with stable 6.x-1.2 version.
See also : http://drupal.org/node/395836

For a pseudo patch see #3.

pomliane’s picture

Status: Active » Needs review

In exif.module,
line 116, under
$tmp = $node->$field_name;
add

if ($key == 'gps_gpslatitude') {
            $value = _exif_DMS2D($value, $data['gps_gpslatituderef']);
            }
            elseif ($key == 'gps_gpslongitude') {
            $value = _exif_DMS2D($value, $data['gps_gpslongituderef']);
            }

line 255 : replace
if ($key == 'gps_latitude') {
with
if ($key == 'gpslatitude') {
line 256 : replace
$value = _exif_DMS2D($value, $data['gps_gpslatituderef']);
with
<$value = _exif_DMS2D($value, $data['gpsgpslatituderef']);
line 258 : replace
<if ($key == 'gps_longitude') {
with
<if ($key == 'gpslongitude') {
line 259 : replace
<$value = _exif_DMS2D($value, $data['gps_gpslongituderef']);
with
<$value = _exif_DMS2D($value, $data['gpslongituderef']);
With these editions, things seem OK : the Exif admin menu shows GPS data and not the word "Array", latitude and longitude are displayed in CCK fields and the "-" is added when required (CCK fields for latitude reference (gpslatituderef) and longitude (gpslongituderef) reference have to be set up for the content type).

rapsli’s picture

Status: Needs review » Needs work

please post a patch against the 6-1 version

pomliane’s picture

Status: Needs work » Needs review
StatusFileSize
new1.7 KB

Here it is.

rapsli’s picture

This patch looks weird... the piece of code you insert is called later on in nodeapi

pomliane’s picture

Indeed.
But, on my system, without the first part, insertions (from node data) in database fail with SQL warnings/errors.
And the second one is required here to have Long/Lat values displayed in the test page (at least).

emagus’s picture

subscribing

gerhard killesreiter’s picture

Status: Needs review » Needs work

Powered by Dreditor.

+++ exif.module.patched	2010-01-26 07:25:13.000000000 -0400
@@ -114,10 +114,17 @@ function exif_nodeapi(&$node, $op, $teas
+            }

This part is only needed because the reformat function is called with different sets of data. When called from the admin/settings page, the gps fields look like "gpslongitude", when called during saving the node, they look as here. This is why the reformat function doesn't act on these fields.

+++ exif.module.patched	2010-01-26 07:25:13.000000000 -0400
@@ -114,10 +114,17 @@ function exif_nodeapi(&$node, $op, $teas
+            if (in_array($key, $date_array)) {

Please don't destroy the formatting.

+++ exif.module.patched	2010-01-26 07:25:13.000000000 -0400
@@ -252,11 +259,11 @@ function _exif_reformat($data) {
+    elseif ($key == 'gpslongitude') {

This fixes the admin/settings page but doesn't help node_save.

This patch needs some work, maybe I find some time.

Powered by Dreditor.

gerhard killesreiter’s picture

Priority: Critical » Normal
Status: Needs work » Needs review
StatusFileSize
new5.52 KB

Here is a patch that works for me.

rapsli’s picture

Hunk #1 FAILED at 103.
Hunk #2 succeeded at 266 (offset 77 lines).
Hunk #3 succeeded at 275 (offset 77 lines).
Hunk #4 FAILED at 320.
Hunk #5 succeeded at 332 with fuzz 2 (offset 66 lines).
Hunk #6 succeeded at 366 (offset 66 lines).

can you check this again? Applied patch against 6--1

gerhard killesreiter’s picture

Status: Needs review » Needs work

Yeah, I started from the released version, my mistake.

I've seen that the dev branch has a exif-location module, should the gps stuff go in there. I am not fond of location.module...

rapsli’s picture

Lets keep the location.module where it is and put the GPS stuff in the main module. I haven't really looked at the location module. I just put it in there, so it can be tested. Probably it would make though sense to get it all into one...

iancawthorne’s picture

I've tried the patch at #5 and also the latest dev version of the module with the "Exif Location" module.

Both work for me, however in both cases, when the longitude is "west", the value is not being set as negative.

Can anyone help with this?

zzolo’s picture

StatusFileSize
new945 bytes

New patch with only the index name fixes, as this is the focus of this issue.

zzolo’s picture

Please ignore last patch. The ref fields are not named correctly.

zzolo’s picture

StatusFileSize
new1.84 KB

New patch for just the gps fields. Though @killes approach of standardizing the arrays is a better approach.

zzolo’s picture

Status: Needs work » Needs review
rapsli’s picture

patch seems pretty simple. Can anybody else confirm the patch?

kdebaas’s picture

Yes, patch works for me.

rapsli’s picture

anybody else? I'll commit it with one or two more people confirming the patch

cashwilliams’s picture

Yep, patch working for me. Please commit :D

emagus’s picture

yeah, works. please commit. Thanx!

rapsli’s picture

... give me to the end of the week

rapsli’s picture

Status: Needs review » Fixed

:) ... this patch is already in the dev version...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.