Page 1 of 2

Feature Request: Get Geotag out of EXIF and convert it

Posted: 31 Jan 2009, 11:29
by Maultrommel
Hi Jan (and everybody else)

I really love the new Beta of Phocagallery, it brings exactly the functions I missed so desperately...! I started geotagging my pictures with Picasa and love the possibility to show this information on a Google-Map.

However, I ran into two main problems:

1. Phocagallery doesn't even seem to import the EXIF-information about the GPS-Position. If I check my pictures in Irfanview, it shows:
GPS information: -
GPSVersionID - 0.0.2.2
GPSLatitudeRef - N
GPSLatitude - 50 42 58.91
GPSLongitudeRef - W
GPSLongitude - 1 46 5.62
GPSAltitudeRef - Sea level
GPSAltitude - 0 m
Apparently, Phocagallery doesn't know how to handle this information and there are no GPS-Coordinates in the detail view of the file. It would be great if phocagallery could read and use this informations.

2. While trying to find the error (solution), I typed manually filled my geocoordinates in. And stumbled across another problem. Phocagallery can handle latitude and longitude, but no gradually numbers. So I looked up a way (here)to convert my position into lat/long:

Code: Select all

function gps_konverter($pos)
  {
  preg_match ('#(\d+)\s*°\s*(\d+)\s*\'\s*(\d+)(?:[,.](\d+))?\s*"#U' , $pos , $items);

  if (empty ($items)) return false;

  array_shift ($items);
  list ($deg , $min , $sec , $trail) = $items;

  return $deg  +  $min / 60  +  ($sec . '.' . $trail) / 3600;
  } 
But even after a long time search I wasn't able to find the correct file where I should enter this piece of code. I assume it should belong somewhere where the images are imported but I wasn't lucky in finding it.

It would be great if somebody could give me hint of where I could put my code? I.e. where the imported files are handled.

Thanks Samuel

BTW: Another great feature concerning the handling of EXIF-data would be the abilty, to import EXIF-descriptions into the normal descriptions of a picture.

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 02 Feb 2009, 00:38
by Jan
Hi,

1. Phoca Gallery display informations of EXIF tags which you will define in parameters component, so I e.g. have defined for picture:
GPS.GPSLatitudeRef;GPS.GPSLatitude;GPS.GPSLongitudeRef;
GPS.GPSLongitude;GPS.GPSAltitudeRef;GPS.GPSAltitude;
GPS.GPSTimeStamp;GPS.GPSStatus;GPS.GPSMapDatum;GPS.GPSDateStamp

and got:
GPSLatitudeRef N
GPSLatitude 47° 24' 50.75"
GPSLongitudeRef E
GPSLongitude 13° 41' 9.144"
GPSAltitudeRef
GPSAltitude 495/1
GPSTimeStamp 7 h 44 m 14 s
GPSStatus A
GPSMapDatum WGS-84
GPSDateStamp 2008-04-11

see:
https://www.phoca.cz/demo/exif-information

Maybe your camere produces other code, if yes then you need to add them into the parameters (Phoca Gallery can display information about all parameters you define and they are produced by camera)

see:
components\com_phocagallery\views\info\view.html.php

Code: Select all

case 'GPSLatitude':
case 'GPSLongitude':
	$exifValue = '';
	if (isset($exif[$section][$name][0])) {
		list($l,$r)	= explode("/",$exif[$section][$name][0]);
		$d			= ($l/$r);
		$exifValue 	.= $d . '° ';
	}
	
	if (isset($exif[$section][$name][1])) {
		list($l,$r)	= explode("/",$exif[$section][$name][1]);
		$m			= ($l/$r);
		
		if ($l%$r>0) {
			$sNoInt = ($l/$r);
			$sInt 	= ($l/$r);
			$s 		= ($sNoInt - (int)$sInt)*60;
			$exifValue 	.= (int)$m . '\' ' . $s . '" ';
		} else {
			$exifValue 	.= $m . '\' ';
			if (isset($exif[$section][$name][2])) {
				list($l,$r)	= explode("/",$exif[$section][$name][2]);
				$s			= ($l/$r);
				$exifValue 	.= $s . '" ';
			}
		}
	}
break;

case 'GPSTimeStamp':
	$exifValue = '';
	if (isset($exif[$section][$name][0])) {
		list($l,$r)	= explode("/",$exif[$section][$name][0]);
		$h			= ($l/$r);
		$exifValue 	.= $h . ' h ';
	}
	
	if (isset($exif[$section][$name][1])) {
		list($l,$r)	= explode("/",$exif[$section][$name][1]);
		$m			= ($l/$r);
		$exifValue 	.= $m . ' m ';
	}
	if (isset($exif[$section][$name][2])) {
		list($l,$r)	= explode("/",$exif[$section][$name][2]);
		$s			= ($l/$r);
		$exifValue 	.= $s . ' s ';
	}

break;
It should work in both cases:
- if you get only degrees and minutes (minutes with decimal values as seconds)
- if you get all three values - degrees, minutes and seconds

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 02 Feb 2009, 19:33
by Maultrommel
Thank you very much for the detailed answer.

I see how you made it - but there must be a bug somewhere...

Because I have the EXIF-Information of the picture, clearly showing the GPS-Position. But there is no Google-Map-Icon next to the picture itself. I only get the icon if I enter the coordinates manually oder point to the position in the backend.

Image
The information shown is for "img_1853.jpg"

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 04 Feb 2009, 02:00
by Jan
Hi, yes this is not ready yet, ... EXIF is not connected with Google maps...

For this I need to set some framework for google maps function ready and then there need to be added the convertor: from degrees, minutes, seconds to latitude, longitude...

Jan

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 08 Feb 2009, 09:31
by Maultrommel
Yes, that would exactly be what I was looking for.
Jan wrote:there need to be added the convertor: from degrees, minutes, seconds to latitude, longitude...
Wouldn't that be what I quotet I my first post - or is it too simple and not sufficent?

If I can be of any assistance, just let me know. I'm waiting for this missing link...

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 10 Feb 2009, 19:12
by Jan
Hi, this is the problem of time, so I hope I find time for doing it soon :-(

Jan

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 03 Jun 2009, 21:39
by Jan
Hi, thank you for this guide. Jan

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 22 Jul 2009, 13:49
by Starkie
Hello Jan,

is there any script for the version 2.50 available yet? The script above doesn't work with the new version.

Starkie

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 12 Oct 2009, 08:39
by kleppen
Hi
any one have a clue how to do it for the phoca gallery version 2.5.8 ?
It displays longetude and latitude information on exif file information.
But I need that info to be added in geotagging automaticly.
I really need it
kind regards
david

Re: Feature Request: Get Geotag out of EXIF and convert it

Posted: 17 Oct 2009, 18:46
by Jan
Hi, such feature is planned, for now I have no clue what should be changed :-(

Jan