Download the PHP package macocci7/php-photo-gps without Composer
On this page you can find all versions of the php package macocci7/php-photo-gps. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download macocci7/php-photo-gps
More information about macocci7/php-photo-gps
Files in macocci7/php-photo-gps
Package php-photo-gps
Short Description Retrieves EXIF GPS data from a photo.
License MIT
Informations about the package php-photo-gps
PHP-PhotoGps
1. Features
PHP-PhotoGps
is a simple library to get GPS data from a photo.
This library reads EXIF data of a jpeg file,
and can convert latitude/longitude into sexagesimal(English/Japanese) or decimal formats,
converts directions into degree with arrow images ,
converts speeds, date stamps and time stamps into human-readable strings.
Remote files (via http: or https:) are supported.
Supported Exif Versions:
- 3.0
- 2.32
- 2.31
- 2.3
- 2.21
- 2.2
- 2.1
2. Contents
- 1. Features
- 2. Contents
- 3. Requirements
- 4. Installation
- 5. Usage
- 5.1. Usage: Basic
- 5.2. Usage: Format Configuration
- 5.2.1. Geo Data Format
- 5.2.2. Direction Data Format
- 5.2.3. Speed Data Format
- 5.2.4. Datestamp Data Format
- 5.2.5. Timestamp Data Format
- 5.3. Usage: Photo List with Checking Geo Data
- 5.4. Usage: Read All GPS Tags
- 5.5. Usage: GPS Attribute Information
- 6. Examples
- 7. LICENSE
- 8. Changelog
3. Requirements
- PHP 8.1 or later
-
GD library enabled
check with commands:
-
Exif enabled
check with commands:
- Composer
4. Installation
5. Usage
- 5.1. Usage: Basic
- 5.2. Usage: Format Configuration
- 5.2.1. Geo Data Format
- 5.2.2. Direction Data Format
- 5.2.3. Speed Data Format
- 5.2.4. Datestamp Data Format
- 5.2.5. Timestamp Data Format
- 5.3. Usage: Photo List with Checking Geo Data
- 5.4. Usage: Read All GPS Tags
- 5.5. Usage: GPS Attribute Information
5.1. Usage: Basic
- 5.1.1. PHP
- 5.1.2. Output
- 5.1.3. Details
5.1.1. PHP
- BasicUsage.php
5.1.2. Output
- BasicUsage.txt
5.1.3. Details
- Import autoloader:
require_once __DIR__ . '/../vendor/autoload.php'
use
declaration:use Macocci7\PhpPhotoGps\PhotoGps;
- Instantiation:
new PhotoGps()
ornew PhotoGps($path)
- Note: If HTTP or HTTPS url is specified as
$path
,download
directory will be created in current directory, and the image will be downloaded in it.
- Note: If HTTP or HTTPS url is specified as
-
Language:
eng
as default.- Get Current:
lang()
- Set as English:
lang('eng')
- Set as Japanese:
lang('ja')
Language Names are defined in
config/PhotoGps.neon
. - Get Current:
- Latitude:
- Decimal:
latitudeD()
- Sexagesimal:
latitudeS()
- Decimal:
- Longitude:
- Decimal:
longitudeD()
- Sexagesimal:
longitudeS()
- Decimal:
- Altitude:
- Decimal:
altitude()
- Strings with prefix & unit:
altitudeS()
- Decimal:
5.2. Usage: Format Configuration
- 5.2.1. Geo Data Format
- 5.2.2. Direction Data Format
- 5.2.3. Speed Data Format
- 5.2.4. Datestamp Data Fromat
- 5.2.5. Timestamp Data Format
5.2.1. Geo Data Format
for latitudeS()
and longitudeS()
.
- 5.2.1.1. PHP
- 5.2.1.2. Output
- 5.2.1.3. Details
5.2.1.1. PHP
- ConfigFormat.php
5.2.1.2. Output
- ConfigFormat.txt
5.2.1.3. Details
- Get Format:
format()
- Set Format:
format($format)
- Reset Format:
resetFormat()
- Default Format:
{ref:u}{degrees:v}{degrees:u}{minutes:v}{minutes:u}{seconds:v}{seconds:u}
-
Format-Tags:
Item Tag eng
ja
Ref {ref:u} N 北緯 Degrees Value {degrees:v} 12 12 Degrees Unit {degrees:u} ° 度 Minutes Value {minutes:v} 34 34 Minutes Unit {minutes:u} ' 分 Seconds Value {seconds:v} 56 56 Seconds Unit {seconds:u} " 秒 latitudeS()
andlongitudeS()
use common format.
5.2.2. Direction Data Format
for directionS()
, destBearingS()
and TrackS()
.
- 5.2.2.1. PHP
- 5.2.2.2. Output
- 5.2.2.3. Details
5.2.2.1. PHP
- ConfigDirectionFormat.php
5.2.2.2. Output
- ConfigDirectionFormat.txt
5.2.2.3. Details
- Get Format:
directionFormat()
- Set Format:
directionFormat($format)
- Reset Format:
resetDirectionFormat()
- Default Format:
{ref} {degrees:v}{degrees:u}
-
Format-Tags:
Item Tag eng
ja
Ref {ref:u} T 真北 Degrees Value {degrees:v} 12.34 12.34 Degrees Unit {degrees:u} ° 度 directionS()
,destBearingS()
andTrackS()
use common format.
5.2.3. Speed Data Format
for speedS()
- 5.2.3.1. PHP
- 5.2.3.2. Output
- 5.2.3.3. Details
5.2.3.1. PHP
- ConfigSpeedFormat.php
5.2.3.2. Output
- ConfigSpeedFormat.txt
5.2.3.3. Details
- Get Format:
speedFormat()
- Set Format:
speedFormat($format)
- Reset Format:
resetSpeedFormat()
- Default Format:
{speed:v}{speed:u}
-
Format-Tags:
Item Tag eng
ja
Speed Value {speed:v} 12.34 12.34 Speed Unit {speed:u} km/h キロメートル/時
5.2.4. Datestamp Data Format
for datestamp()
- 5.2.4.1. PHP
- 5.2.4.2. Output
- 5.2.4.3. Details
5.2.4.1. PHP
- ConfigDatestampFormat.php
5.2.4.2. Output
- ConfigDatestampFormat.txt
5.2.4.3. Details
- Get Format:
datestampFormat()
- Set Format:
datestampFormat($format)
- Reset Format:
resetDatestampFormat()
- Default Format:
eng
:Y/m/d
ja
:Y年m月d日
- Format parameter strings: See PHP Official
5.2.5. Timestamp Data Format
for timestamp()
- 5.2.5.1. PHP
- 5.2.5.2. Output
- 5.2.5.3. Details
5.2.5.1. PHP
- ConfigTimestampFormat.php
5.2.5.2. Output
- ConfigTimestampFormat.txt
5.2.5.3. Details
- Get Format:
timestampFormat()
- Set Format:
timestampFormat($format)
- Reset Format:
resetTimestampFormat()
- Default Format:
eng
:H:i:s
ja
:H時i分s秒
- Format parameter strings: See PHP Official
5.3. Usage: Photo List with Checking Geo Data
Geo Data means latitude and longitude here.
The code below creates a list of photos in the dir img/
.
- 5.3.1. PHP
- 5.3.2. Result
- 5.3.3. Details
5.3.1. PHP
- CheckGeoData.php
5.3.2. Result
-
CheckGeoData.md
Photo List: Geo Data
Image Geo Coordinate o 31.53324552730697, 35.47923749904281
31°31'59.7"N, 35°28'45.3"E
北緯31度31分59.7秒, 東経35度28分45.3秒
(Below Sea Level) 422.00 m (負値海抜) 422.00 メートルo -20.18913849132269, -67.58772465286874
20°11'20.9"S, 67°35'15.8"W
南緯20度11分20.9秒, 西経67度35分15.8秒
(Above Sea Level) 3700.00 m (正値海抜) 3700.00 メートルo 35.87235861111111, 139.78356388888889
35°52'20.5"N, 139°47'0.8"E
北緯35度52分20.5秒, 東経139度47分0.8秒
(Above Ellipsoidal Surface) 3.70 m (正値楕円体高) 3.70 メートルo 38.26386166666666, 140.87085083333335
38°15'49.9"N, 140°52'15.1"E
北緯38度15分49.9秒, 東経140度52分15.1秒
(Above Ellipsoidal Surface) 42.00 m (正値楕円体高) 42.00 メートルo 37.05727416666667, 140.89244166666666
37°3'26.2"N, 140°53'32.8"E
北緯37度3分26.2秒, 東経140度53分32.8秒
(Above Ellipsoidal Surface) 13.00 m (正値楕円体高) 13.00 メートルx No Geo Data No Altitude Data
5.3.3. Details
- Load GPS Data from a photo:
load($path)
- Check If GPS Data Exists:
hasGps()
- Check If Geo Data Exists:
hasGeo()
- Check If Altitude Exists:
hasAltitude()
5.4. Usage: Read All GPS Tags
gps()
method returns all Exif tags which has GPS
prefix.
- 5.4.1. PHP
- 5.4.2. Result
- 5.4.3. Details
5.4.1. PHP
- ReadAllGpsTags.md
5.4.2. Result
-
ReadAllGpsTags.md
Exif: GPS Tags
File with Fake GPS via HTTP
|Attribute|Value| |:---|---:| |ExifVersion|0300| |Image Direction|
M 352.40°| |Speed|12.45kt| |Track|M 62.90°| |Destination Bearing|M 138.69°| |Datestamp|2018/03/31 (UTC)| |Timestamp|02:22:14 (UTC)||Tag|Value| |:---|---:| |GPS_IFD_Pointer|366| |GPSLatitudeRef|N| |GPSLatitude|31/1
34/1
8083/1000| |GPSLongitudeRef|E| |GPSLongitude|35/1
30/1
5245/1000| |GPSAltitudeRef|3| |GPSAltitude|42200/100| |GPSTimeStamp|2/1
22/1
14/1| |GPSSpeedRef|N| |GPSSpeed|22778/1829| |GPSTrackRef|M| |GPSTrack|157243/2500| |GPSImgDirectionRef|M| |GPSImgDirection|195581/555| |GPSDestBearingRef|M| |GPSDestBearing|83632/603| |GPSDateStamp|2018:03:31|File with Fake GPS via HTTPS
|Attribute|Value| |:---|---:| |ExifVersion|0300| |Image Direction|
T 278.63°| |Speed|100.00mph| |Track|T 268.44°| |Destination Bearing|T 273.47°| |Datestamp|2015/06/07 (UTC)| |Timestamp|01:31:46 (UTC)||Tag|Value| |:---|---:| |GPS_IFD_Pointer|214| |GPSLatitudeRef|S| |GPSLatitude|20/1
11/1
20898/1000| |GPSLongitudeRef|W| |GPSLongitude|67/1
35/1
15808/1000| |GPSAltitudeRef|0| |GPSAltitude|370000/100| |GPSTimeStamp|1/1
31/1
46/1| |GPSSpeedRef|M| |GPSSpeed|100/1| |GPSTrackRef|T| |GPSTrack|143885/536| |GPSImgDirectionRef|T| |GPSImgDirection|115074/413| |GPSDestBearingRef|T| |GPSDestBearing|188418/689| |GPSDateStamp|2015:06:07|Local File with GPS
|Attribute|Value| |:---|---:| |ExifVersion|0300| |Image Direction| T 306.25°| |Speed|1.60mph| |Track|M 359.90°| |Datestamp|2023/09/18 (UTC)| |Timestamp|03:43:32 (UTC)||Tag|Value| |:---|---:| |GPS_IFD_Pointer|908| |GPSLatitudeRef|N| |GPSLatitude|37/1
3/1
26187/1000| |GPSLongitudeRef|E| |GPSLongitude|140/1
53/1
32790/1000| |GPSAltitudeRef|0| |GPSAltitude|1300/100| |GPSTimeStamp|3/1
43/1
32/1| |GPSSpeedRef|M| |GPSSpeed|16/10| |GPSTrackRef|M| |GPSTrack|224936/625| |GPSImgDirectionRef|T| |GPSImgDirection|191409/625| |GPSDateStamp|2023:09:18|No GPS tags
|Attribute|Value| |:---|---:| |ExifVersion|0220| No GPS data.
5.4.3. Details
-
use
declaration:use Macocci7\PhpPhotoGps\Helpers\Dir;
to clear entries in
download
directory. -
use
declaration:use Macocci7\PhpPhotoGps\Helpers\Arrow;
to create arrow images.
- Clear entries in a directory:
Dir::clear($dir)
- Get Image Direction:
- As Float:
direction()
returnsnull
if not found. - As String:
directionS()
returnnull
if not found.
- As Float:
- Get Speed:
- As Float:
speed()
returnsnull
if not found. - As String:
speedS()
returnsnull
if not found.
- As Float:
- Get Track (Direction of Movement):
- As Float:
track()
returnsnull
if not found. - As String:
trackS()
returnsnull
if not found.
- As Float:
- Get Destination Bearing:
- As Float:
destBearing()
returnsnull
if not found. - As String:
destBearingS()
returnsnull
if not found.
- As Float:
- Get Date Stamp:
datestamp()
returnsnull
if not found. - Get Time Stamp:
timestamp()
returnsnull
if not found. -
Create Arrow Image:
Arrow::make($degree)->save($pathArrow)
$degree
: must be in clockwise degrees. (0° ~ 360°)Arrow:make()
: returns the instance ofIntervention\Image\Interfaces\ImageInterface
(v3.3)Returning HTTP Response with it is available.-
See more: Intervention/image Official Documentresponse()
has removed since v3. - Note:
- If the reference is 'M' (Magnetic North), the arrow image shows the relative direction from Magnetic North(Magnetic North upward).
- Magnetic North pole moves over time. See more.
-
Note:
- All photos in this repository were taken by macocci7 with mobile phone, and free to use.
-
Some of GPS data was manually injected with some tools.
-
GIMP v2.10.34 used for:
GPSLatitudeRef
GPSLatitude
GPSLongitudeRef
GPSLongitude
GPSAltitudeRef
GPSAltitude
GIMP can edit only geo tags.
-
Exif Tool by Phil Harvey v12.72 used for:
- All other GPS tags
Exif Tool can edit all writable GPS tags.
However, Exif Tool currently cannot set
GPSSpeedRef
asK
(maybe a bug).
-
5.5. Usage: GPS Attribute Information
- 5.5.1. PHP
- 5.5.2. Result
- 5.5.3. Details
5.5.1. PHP
- GpsAttrInfo.php
5.5.2. Result
-
GpsAttrInfo.md
Exif0300: GPS Attribute Information
Field Name Type Count Values Default Separator GPSVersion BYTE 4 --- 2.4.0.0 . GPSVersionID BYTE 4 --- 2.4.0.0 . GPSLatitudeRef ASCII 2 N: North latitude
S: South latitudeNone --- GPSLatitude RATIONAL 3 --- None --- GPSLongitudeRef ASCII 2 E: East longitude
W: West longitudeNone --- GPSLongitude RATIONAL 3 --- None --- GPSAltitudeRef BYTE 1 0: Positive ellipsoidal height (at or above ellipsoidal surface)
1: Negative ellipsoid height (below ellipsoidal surface)
2: Positive sea level value (at or above sea level reference)
3: Negative sea level value (below sea level reference)0 GPSAltitude RATIONAL 1 --- None --- GPSTimeStamp RATIONAL 3 --- None --- GPSSatellites ASCII 0 --- None --- GPSStatus ASCII 2 A: Measurement in progress
V: Measurement interruptedNone --- GPSMeasureMode ASCII 2 2: 2-dimensional measurement
3: 3-dimensional measurementNone --- GPSDOP RATIONAL 1 --- None --- GPSSpeedRef ASCII 2 K: Kilometers per hour
M: Miles per hour
* N: KnotsK --- GPSSpeed RATIONAL 1 --- None --- GPSTrackRef ASCII 2 T: True direction
M: Magnetic directionT --- GPSTrack RATIONAL 1 --- None --- GPSImgDirectionRef ASCII 2 T: True direction
M: Magnetic directionT --- GPSImgDirection RATIONAL 1 --- None --- GPSMapDatum ASCII 0 --- None --- GPSDestLatitudeRef ASCII 2 N: North latitude
S: South latitudeNone --- GPSDestLatitude RATIONAL 3 --- None --- GPSDestLongitudeRef ASCII 2 E: East longitude
W: West longitudeNone --- GPSDestLongitude RATIONAL 3 --- None --- GPSDestBearingRef ASCII 2 T: True direction
M: Magnetic directionT --- GPSDestBearing RATIONAL 1 --- None --- GPSDestDistanceRef ASCII 2 K: Kilometers
M: Miles
* N: Nautical milesK --- GPSDestDistance RATIONAL 1 --- None --- GPSProcessingMethod UNDEFINED 0 GPS: GPS [GPSMeaMeasureMode: 2 or 3]
QZSS: Quasi-Zenith Satellite System [GPSMeasureMode: 2 or 3]
GALILEO: Galileo System [GPSMeasureMode: 2 or 3]
GLONASS: Global Navigation Satellite System [GPSMeasureMode: 2 or 3]
BEIDOU: Beidou Satellite Positioning System [GPSMeasureMode: 2 or 3]
NAVID: Navigation Indian Constellation System [GPSMeasureMode: 2 or 3]
CELLID: Mobile Phone Base Stations [GPSMeasureMode: 2 (generally)]
WLAN: Wireless LAN [GPSMeasureMode: 2 (generally)]
* MANUAL: Manual input [GPSMeasureMode: (not recorded)]None --- GPSAreaInformation UNDEFINED 0 --- None --- GPSDateStamp ASCII 11 --- None --- GPSDifferential SHORT 1 0: Measurement without differential correction
1: Differential correction appliedNone --- GPSHPositioningError RATIONAL 1 --- None ---
5.5.3. Details
-
use
declaration:use Macocci7\PhpPhotoGps\Helpers\Gps;
to use GPS Data Interface.
-
Get GPS Tag Attributes:
Gps::def()
orGps::def($tagName)
it returns
null
if not found.GPS Tag Attributes are defined in
config/Gps.neon
.The structure of Hash array returned by
Gps::def()
is as below:exifXXXX
:XXXX
is replaced with Exif Version number.fields
:- TagName: like
GPSVersionID
orGPSAltitude
type
: based on Exif Standardcount
: based on Exif Standarddefault
: based on Exif Standardvalues
: based on Exif Standardseparator
: originaly added
- TagName: like
Object-like dot-separated specifiers are available for
$tagName
.For example,
Gps::def('exif0300.fields.GPSLatitudeRef')
returns:
6. Examples
- BasicUsage.txt
- CheckGeoData.md
- ConfigFormat.txt
- ConfigDirectionFormat.txt
- ConfigSpeedFormat.txt
- ReadAllGpsTags.md
- GpsAttrInfo.md
7. LICENSE
MIT
8. Changelog
CHANGELOG
Document created: 2023/09/30
Document updated: 2025/01/04
Copyright 2023 - 2025 macocci7