antodippo/exif-reader

A simple, straightforward and fully typed, Exif reader library

1.0.0 2020-05-22 14:59 UTC

This package is auto-updated.

Last update: 2024-04-23 22:37:46 UTC


README

Latest Stable Version PHP7.2 build PHP7.3 build PHP7.4 build

codecov Mutation testing badge Type coverage badge License: MIT

This is a simple, straightforward and fully typed Exif reader library. It's based on exif_read_data PHP function, but it avoids a lot of headaches. It requires the Exif extension to be installed.

The simplest way to install it is through Composer:

$ composer require antodippo/exif-reader

To use it, it's as simple as this:

$exifReader = new Reader();

try {
    $exifData = $exifReader->read('/tests/images/with-coordinates.jpg');
} catch (CannotReadExifData $e) {
    echo 'Cannot read exif data: ' . $e->getMessage();
}

echo $exifData->getCameraData()->getMaker();        // Sony
echo $exifData->getCameraData()->getModel();        // F5121
echo $exifData->getFileData()->getTakenDate();      // 2017-06-09 18:43:32
echo $exifData->getGeoLocation()->getLatitude();    // 64.25784
echo $exifData->getGeoLocation()->getLongitude();   // -21.121168

Running the project and contributing

The library comes with a Docker setup. To build the containers:

$ make setup

To run the pipeline (static analysis, tests, mutations) for a specific PHP version:

$ make php72-pipeline
$ make php73-pipeline
$ make php74-pipeline