A simple, straightforward and fully typed, Exif reader library

0.1.0 2023-05-29 17:08 UTC

This package is auto-updated.

Last update: 2024-10-29 20:59:49 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 abdelrahmanelmaghraby/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