1. Go to this page and download the library: Download alchemy/phpexiftool library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alchemy / phpexiftool example snippets
onolog\Logger;
use PHPExiftool\Reader;
use PHPExiftool\Driver\Value\ValueInterface;
$logger = new Logger('exiftool');
$reader = Reader::create($logger);
$metadataBag = $reader->files(__FILE__)->first();
foreach ($metadataBag as $metadata) {
if (ValueInterface::TYPE_BINARY === $metadata->getValue()->getType()) {
echo sprintf("\t--> Field %s has binary data" . PHP_EOL, $metadata->getTagGroup());
} else {
echo sprintf("\t--> Field %s has value(s) %s" . PHP_EOL, $metadata->getTagGroup(), $metadata->getValue()->asString());
}
}
use Monolog\Logger;
use PHPExiftool\Reader;
use PHPExiftool\Driver\Value\ValueInterface;
$logger = new Logger('exiftool');
$reader = Reader::create($logger);
$reader
->in(array('documents', '/Picture'))
->extensions(array('doc', 'jpg', 'cr2', 'dng'))
->exclude(array('test', 'tmp'))
->followSymLinks();
foreach ($reader as $data) {
echo "found file " . $data->getFile() . PHP_EOL;
foreach ($data as $metadata) {
if (ValueInterface::TYPE_BINARY === $metadata->getValue()->getType()) {
echo sprintf("\t--> Field %s has binary data" . PHP_EOL, $metadata->getTagGroup());
} else {
echo sprintf("\t--> Field %s has value(s) %s" . PHP_EOL, $metadata->getTagGroup(), $metadata->getValue()->asString());
}
}
}
onolog\Logger;
use PHPExiftool\Writer;
use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Driver\Metadata\MetadataBag;
use PHPExiftool\Driver\Tag\IPTC\ObjectName;
use PHPExiftool\Driver\Value\Mono;
$logger = new Logger('exiftool');
$writer = Writer::create($logger);
$bag = new MetadataBag();
$bag->add(new Metadata(new ObjectName(), new Mono('Pretty cool subject')));
$writer->write('image.jpg', $bag);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.