PHPEXIFTOOL get specific tag + value

Started by jfbb6x, May 25, 2022, 10:48:57 AM

Previous topic - Next topic

jfbb6x

Hi There can anyone help please?

I'm a newbie using phpexif tool. I'm able to obtain all the metadata of a .mp4 file using the example provided on the github repos:
"
<?php

require __DIR__ . '/vendor/autoload.php';

use Monolog\Logger;
use PHPExiftool\Reader;
use PHPExiftool\Driver\Value\ValueInterface;

$logger = new Logger('exiftool');
$reader = Reader::create($logger);

$metadatas = $reader->files(__FILE__)->first();

foreach ($metadatas as $metadata) {
    if (ValueInterface::TYPE_BINARY === $metadata->getValue()->getType()) {
        echo sprintf("\t--> Field %s has binary datas" . PHP_EOL, $metadata->getTag());
    } else {
        echo sprintf("\t--> Field %s has value(s) %s" . PHP_EOL, $metadata->getTag(), $metadata->getValue()->asString());
    }
}
"

How could I adapt this example to just pull in the GPS related values of the file? I assume its related to the 'getTag()' function but I've been unable to figure out how to achieve this. I would be happy to obtain each tagname individulaly (i.e latitude + longitude) if all gps data is not possible. Also to confirm, the file does have GPS values that are showing in the $metadata array fully outputted.

Cheers
J

Phil Harvey

You would be better off asking the PHPExifTool people about this.  I haven't used that interface myself.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).