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
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