alchemy / phpexiftool
Exiftool driver for PHP
Installs: 182 435
Dependents: 6
Suggesters: 1
Security: 0
Stars: 34
Watchers: 14
Forks: 43
Open Issues: 8
Requires
- php: ^7.4 || ^8.2
- ext-dom: *
- ext-json: *
- cache/array-adapter: ^1.2
- doctrine/cache: ^1.0
- doctrine/collections: ^1.0
- exiftool/exiftool: *
- symfony/console: ^5 || ^6.2
- symfony/css-selector: ^5 || ^6.2
- symfony/dom-crawler: ^5 || ^6.2
- symfony/monolog-bridge: ^5.4 || ^6.2
- symfony/process: ^5 || ^6
Requires (Dev)
- jms/serializer: ~3
- phpunit/phpunit: ^9.6.7
- symfony/finder: ^5
- symfony/yaml: ^5 || ^6
Suggests
- jms/serializer: To serialize tags
- symfony/yaml: To serialize tags in Yaml format
- 4.x-dev
- 4.1.1
- 4.1.0
- 4.0.1
- 4.0.0
- 3.1.x-dev
- 3.1.2
- 3.1.1
- 3.0.x-dev
- 3.0.1
- 3.0.0
- 2.2.x-dev
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.x-dev
- 2.1.2
- 2.0.x-dev
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.0
- dev-master / 0.5.x-dev
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-PS-578_dictionary-save-client-side
- dev-SILEX2
- dev-feature/improve-error
- dev-0.4.1-mwg-metadata-copy
This package is auto-updated.
Last update: 2024-12-16 09:19:33 UTC
README
This project is a fork of phpexiftool/phpexiftool.
PHP Exiftool is an Object Oriented driver for Phil Harvey's Exiftool (see http://www.sno.phy.queensu.ca/~phil/exiftool/). Exiftool is a powerful library and command line utility for reading, writing and editing meta information written in Perl.
PHPExiftool provides an intuitive object oriented interface to read and write metadata.
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": { "alchemy/phpexiftool": "^4.0" } }
Usage
Exiftool Reader
A simple example : how to read metadata from a file:
<?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); $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()); } }
An example with directory inspection :
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()); } } }
Exiftool Writer
<?php require __DIR__ . '/vendor/autoload.php'; use Monolog\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);
License
Project licensed under the MIT License