Posted by raintonr on September 25, 2007 at 4:12am
| Project: | Exif |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
If the location.module is installed, and the user doesn't enter a location why not have the GPS co-ords pulled from the Exif tags?
This is sort of a duplicate of http://drupal.org/node/143071 but belongs more in the Exif module.
I made a start at such functionality and it's working on our site. See http://drupal.org/node/143071#comment-310009 for quick and dirty code.
This code needs a bit of cleaning but the basic idea is working. Probably improvements:
1. Check for location.module installed/active properly.
2. Couple of configuration options to a) activate this feature, b) determine what happens on image re-submission.
Comments
#1
Here's another patch with:
- Improved checking for location.module.
- Admin menu items to enable/disable the function & start rescan.
- Cron hook to process image files in batches if scan is started. Allows GPS locations to be harvested from existing images when scan restart admin option is chosen.
#2
Oops... slight problem with the last patch. Completely disables Exif if locations are not present on the module. This one should be better.
#3
Do you think you could make a version of your patch that's in line with the drupal patch guidelines?
http://drupal.org/patch/create
Specifically cvs -up
#4
Hi,
diff -up patch attached as requested.
This is between the release I originally patched (1.0) and my update. I notice some things have changed a bit in 1.1. If you don't have time to do this merge I can try and update to 1.1 and re-do my changes. Please let me know if that's required.
#5
Marked #363894: Fill location information on GPS Exif tags V6 as a duplicate.
#6
can somebody help me on this? I'm working on the D6 branch -> the feature to integrate Coords into CCK. It's actually pretty simple, but: I don't know how to intepret the data:
the exif comes out as an array:
#
value (Array, 3 elements)
* 0 (String, 4 characters ) 49/1
* 1 (String, 4 characters ) 44/1
* 2 (String, 19 characters ) 2147483631/82532375
This is just the latitute. How do I have to put this together in order to make real coords?
Plus. Location CCK: In which way do the coords have to be entered? Please provide an example. I'll then make sure to get that in.
#7
To figure out how to get co-ords from EXIF, look in the patch, specifically at these parts:
function _exif_DMS2D($entry) {
$value = $entry->getValue();
$degrees = $value[0][0] / $value[0][1];
$minutes = $value[1][0] / $value[1][1];
$seconds = $value[2][0] / $value[2][1];
return $degrees + $minutes/60 + $seconds/3600;
}
...
$entry = $gps->getEntry(PelTag::GPS_LATITUDE);
if (!$entry) return FALSE;
$GPS_LATITUDE = _exif_DMS2D($entry);
$entry = $gps->getEntry(PelTag::GPS_LATITUDE_REF);
if (!$entry) return FALSE;
if ($entry->getValue() == 'S') $GPS_LATITUDE = -$GPS_LATITUDE;
$entry = $gps->getEntry(PelTag::GPS_LONGITUDE);
if (!$entry) return FALSE;
$GPS_LONGITUDE = _exif_DMS2D($entry);
$entry = $gps->getEntry(PelTag::GPS_LONGITUDE_REF);
if (!$entry) return FALSE;
if ($entry->getValue() == 'W') $GPS_LONGITUDE = -$GPS_LONGITUDE;
#8
subscribing
#9
@rapsli Was #7 any good or do you need more info?
#10
#11
i'm trying to get this working with the latest D6 version. the patch is for a very old version and does not help me. can anyone give me suggestion where to tweak the module to get it working?
#12
I'd given up getting this inserted into the exif module and wrote a small exif_location module. Will post more details when it's fit for public consumption ;)
#13
i am happy for code in any condition. waiting for a solution to this problem to send a site live.
#14
great news raintonr. waiting patiently
#15
subscribing - waiting for exif_location
#16
applied a patch to head. let's get this one here moving on next. Anybody willing to volonteer for a patch? I'm more than welcome to apply it.
#17
Hi Rapsli,
Works only for me if I prepend "gps_" to "gpslatitude" and "gps_gpslongitude" in lines 240 and 243 respectively.
if ($key == 'gps_gpslatitude') {$value = _exif_DMS2D($value, $data['gpslatituderef']);
}
elseif ($key == 'gps_gpslongitude') {
$value = _exif_DMS2D($value, $data['gpslongituderef']);
}
#18
Re: #17, see patch here: http://drupal.org/node/473140#comment-2186358
#19
#20
Actually, this isn't a duplicate.
I spoke about making a exif_location module though, please see attached tar file. Think it would be nice to bundle this with exif module.
Testing of this was hardly thorough, but works for me. YMMV.
#21
Anyone tried #20? Thoughts on integrating or bundling with the EXIF module?
#22
let me have a look at this next week when there's more time.
#23
I tried the code in #20. Worked like a charm.
#24
How did you do it? What fields do you have to add, and what else has to be done? I just can't get it to work...
#25
The problem is that, currently, you have to account for a few different issues:
1) The $op in hook_nodeapi that should handle the storage of EXIF information in the $node object. IMO, this should be "presave".
2) The correct key usage in the function _exif_reformat(): "gps_gpslatitude" and "gps_gpslongitude" instead of "gps_latitude" and "gps_longitude".
3) The correct execution order of anything in hook_nodeapi() in exif_location module relative to the code in (1) above.
It isn't that complicated, but it requires a few hacks in Exif module.
I want to work on this, but I have no idea of the latest code status for Exif module. It seems dispersed.
@rapsli: are you willing to make a new release soon that incorporates al these changes?
#26
this is still experimental, as I didn't get around testing it. Just had a brief look at it. Let's find out, how well the community is working. It's committed to HEAD.
#27
committed this to 6.1 branch.
#28
Automatically closed -- issue fixed for 2 weeks with no activity.
#29
I try to use the "Exif Location" Sub-Module.
The Location Module is installed and coordinate input is activated for the nodetype. While creating the node I can see the lat and lon fields. In Exif-Module settings the nodetype is active too.
But after uploading a picture with GPS data, the coordinate is not in the Location module. Do I have to create additional CCK fields? Forgotten settings?
Can anybody give me a How-To of bringing GPS data from the filefield picture to the location field via "Exif Location"?
If I understand that and it works here, I can write a README for the "Exif Location" Sub-Module.
#30
#31
my solution:
vi "exif/exif.class.php"
goto line 77 nearby, replace:
if ($tagName['section'] != 'iptc') {with:
if ($tagName['section'] == 'gps') {$info[$tagName['section'] .'_'. $tagName['tag']] = $arSmallExif[$tagName['tag']];
}
elseif ($tagName['section'] != 'iptc') {
finished. it works!
addtionally, for the photo without gps information, it would display warnning! so
modify the exif.module, line 282
function _exif_DMS2D($value, $ref) {if (!$value) {
return 0;
}