I would like to extract the GPS EXIF tag from pictures using php.
I'm using the exif_read_data()
that returns a array of all tags + data :
GPS.GPSLatitudeRef: N
GPS.GPSLatitude:Array ( [0] => 46/1 [1] => 5403/100 [2] => 0/1 )
GPS.GPSLongitudeRef: E
GPS.GPSLongitude:Array ( [0] => 7/1 [1] => 880/100 [2] => 0/1 )
GPS.GPSAltitudeRef:
GPS.GPSAltitude: 634/1
I don't know how to interpret 46/1 5403/100 and 0/1 ? 46 might be 46° but what about the rest especially 0/1 ?
angle/1 5403/100 0/1
What is this structure about ?
How to convert them to "standard" ones (like 46°56′48″N 7°26′39″E from wikipedia) ? I would like to pass thoses coordinates to the google maps api to display the pictures positions on a map !
To get the altitude value, you can use the following 3 lines:
I'm using the modified version from Gerald Kaszuba but it's not accurate. so i change the formula a bit.
from:
changed to:
It works for me.
This is an old question but felt it could use a more eloquent solution (OOP approach and lambda to process the fractional parts)
In case you need a function to read Coordinates from Imagick Exif here we go, I hope it saves you time. Tested under PHP 7.
i have seen nobody mentioned this: https://pypi.python.org/pypi/LatLon/1.0.2
now using the Coordonates objecct you can do what you want: Example:
(like 46°56′48″N 7°26′39″E from wikipedia)
You than have to convert from ascii, and you are done:
and than printing example:
This is my modified version. The other ones didn't work for me. It will give you the decimal versions of the GPS coordinates.
The code to process the EXIF data:
Prints out in this format:
Here are the functions: