PHPackages                             macocci7/php-photo-gps - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. macocci7/php-photo-gps

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

macocci7/php-photo-gps
======================

Retrieves EXIF GPS data from a photo.

1.8.6(5mo ago)477[1 issues](https://github.com/macocci7/PHP-PhotoGps/issues)MITPHP

Since Oct 9Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/macocci7/PHP-PhotoGps)[ Packagist](https://packagist.org/packages/macocci7/php-photo-gps)[ RSS](/packages/macocci7-php-photo-gps/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (26)Used By (0)

PHP-PhotoGps
============

[](#php-photogps)

1. Features
-----------

[](#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 [![](img/arrow_red_50x50.png)](img/arrow_red_50x50.png),

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

```
use Macocci7\PhpPhotoGps\PhotoGps;

$pg = new PhotoGps(__DIR__ . '/img/my_photo.jpg'); // URL is also available

if ($pg->hasGeo()) {
    echo sprintf(
        "%s, %s\n",
        sprintf(
            "https://www.google.com/maps/place/%s+%s/@%.7f,%.7f,17z/?authuser=0&entry=ttu",
            urlencode($pg->lang('eng')->latitudeS()),
            urlencode($pg->lang('eng')->longitudeS()),
            $pg->latitudeD(),
            $pg->longitudeD()
        ),
        sprintf("%.14f", $pg->latitudeD()),
        sprintf("%.14f", $pg->longitudeD())
    );
}
```

2. Contents
-----------

[](#2-contents)

- [1. Features](#1-features)
- 2. Contents
- [3. Requirements](#3-requirements)
- [4. Installation](#4-installation)
- [5. Usage](#5-usage)
    - [5.1. Usage: Basic](#51-usage-basic)
    - [5.2. Usage: Format Configuration](#52-usage-format-configuration)
        - [5.2.1. Geo Data Format](#521-geo-data-format)
        - [5.2.2. Direction Data Format](#522-direction-data-format)
        - [5.2.3. Speed Data Format](#523-speed-data-format)
        - [5.2.4. Datestamp Data Format](#524-datestamp-data-format)
        - [5.2.5. Timestamp Data Format](#525-timestamp-data-format)
    - [5.3. Usage: Photo List with Checking Geo Data](#53-usage-photo-list-with-checking-geo-data)
    - [5.4. Usage: Read All GPS Tags](#54-usage-read-all-gps-tags)
    - [5.5. Usage: GPS Attribute Information](#55-usage-gps-attribute-information)
- [6. Examples](#6-examples)
- [7. LICENSE](#7-license)
- [8. Changelog](#8-changelog)

3. Requirements
---------------

[](#3-requirements)

- PHP 8.1 or later
- GD library enabled

    check with commands:

    ```
    (php -m; php -i) | grep gd
    ```
- Exif enabled

    check with commands:

    ```
    (php -m; php -i) | grep exif
    ```
- [Composer](https://getcomposer.org/)

4. Installation
---------------

[](#4-installation)

```
composer require macocci7/php-photo-gps
```

5. Usage
--------

[](#5-usage)

- [5.1. Usage: Basic](#51-usage-basic)
- [5.2. Usage: Format Configuration](#52-usage-format-configuration)
    - [5.2.1. Geo Data Format](#521-geo-data-format)
    - [5.2.2. Direction Data Format](#522-direction-data-format)
    - [5.2.3. Speed Data Format](#523-speed-data-format)
    - [5.2.4. Datestamp Data Format](#524-datestamp-data-format)
    - [5.2.5. Timestamp Data Format](#525-timestamp-data-format)
- [5.3. Usage: Photo List with Checking Geo Data](#53-usage-photo-list-with-checking-geo-data)
- [5.4. Usage: Read All GPS Tags](#54-usage-read-all-gps-tags)
- [5.5. Usage: GPS Attribute Information](#55-usage-gps-attribute-information)

### 5.1. Usage: Basic

[](#51-usage-basic)

- [5.1.1. PHP](#511-php)
- [5.1.2. Output](#512-output)
- [5.1.3. Details](#513-details)

#### 5.1.1. PHP

[](#511-php)

- [BasicUsage.php](examples/BasicUsage.php)

    ```
