fieldtronics / phpexiftool
Exiftool driver for PHP
Requires
- php: >=5.3.3
- doctrine/cache: ~1.0
- doctrine/collections: ~1.0
- monolog/monolog: ~1.3
- symfony/console: ~2.0
- symfony/process: ~2.0
Requires (Dev)
- jms/serializer: ~0.10
- sami/sami: ~1.0
- silex/silex: ~1.0
- symfony/css-selector: ~2.0
- symfony/dom-crawler: ~2.0
- symfony/finder: ~2.0
- symfony/yaml: ~2.0
Suggests
- jms/serializer: To serialize tags
- symfony/yaml: To serialize tags in Yaml format
This package is not auto-updated.
Last update: 2025-03-21 23:15:55 UTC
README
PHP Exiftool is an Object Oriented driver for Phil Harvey's Exiftool (see http://www.sno.phy.queensu.ca/~phil/exiftool/). Exiftool is a powerfull library and command line utility for reading, writing and editing meta information written in Perl.
FieldsPHPExiftool provides an intuitive object oriented interface to read and write metadatas.
You will find some example below. This driver is not suitable for production, it is still under heavy development.
Installation
The recommended way to install PHP-Exiftool is through composer.
{
"require": {
"phpexiftool/phpexiftool": "~0.1.0"
}
}
Usage
Exiftool Reader
A simple example : how to read a file metadatas :
<?php
require __DIR__ . '/vendor/autoload.php';
use Monolog\Logger;
use FieldsPHPExiftool\Reader;
use FieldsPHPExiftool\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());
}
}
An example with directory inspection :
use Monolog\Logger;
use FieldsPHPExiftool\Reader;
use FieldsPHPExiftool\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 $MetaDatas) {
echo "found file " . $MetaDatas->getFile() . "\n";
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());
}
}
}
Exiftool Writer
<?php
require __DIR__ . '/vendor/autoload.php';
use Monolog\Logger;
use FieldsPHPExiftool\Writer;
use FieldsPHPExiftool\Driver\Metadata\Metadata;
use FieldsPHPExiftool\Driver\Metadata\MetadataBag;
use FieldsPHPExiftool\Driver\Tag\IPTC\ObjectName;
use FieldsPHPExiftool\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);
License
Project licensed under the MIT License