Feature Request: Get Geotag out of EXIF and convert it

Phoca Gallery - image gallery extension
Maultrommel
Phoca Member
Phoca Member
Posts: 17
Joined: 06 Oct 2008, 08:27

Feature Request: Get Geotag out of EXIF and convert it

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49299
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

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

Post 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
If you find Phoca extensions useful, please support the project
Maultrommel
Phoca Member
Phoca Member
Posts: 17
Joined: 06 Oct 2008, 08:27

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

Post 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"
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49299
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

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

Post 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
If you find Phoca extensions useful, please support the project
Maultrommel
Phoca Member
Phoca Member
Posts: 17
Joined: 06 Oct 2008, 08:27

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

Post 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...
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49299
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

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

Post by Jan »

Hi, this is the problem of time, so I hope I find time for doing it soon :-(

Jan
If you find Phoca extensions useful, please support the project
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49299
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

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

Post by Jan »

Hi, thank you for this guide. Jan
If you find Phoca extensions useful, please support the project
Starkie
Phoca Member
Phoca Member
Posts: 11
Joined: 22 Jul 2009, 13:42

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

Post 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
kleppen
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 02 Oct 2009, 12:06

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

Post 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
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49299
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

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

Post by Jan »

Hi, such feature is planned, for now I have no clue what should be changed :-(

Jan
If you find Phoca extensions useful, please support the project
Post Reply