Giter Site home page Giter Site logo

phpexiftool's Introduction

PHP-Exiftool

Build Status

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

phpexiftool's People

Contributors

4rthem avatar aynsix avatar aztech-dev avatar bburnichon avatar cedcannes avatar gioid avatar jygaulier avatar michalsanger avatar nlegoff avatar nmaillat avatar nousefreak avatar romainneutron avatar simonsimcity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpexiftool's Issues

Error finding exiftool binary

I am getting the following error trying to add exif data to an image:

**Unable to get exiftool binary**

Error: An Internal Error Has Occurred.
Stack Trace

    APP/Vendor/PHPExiftool/Exiftool.php line 50 → PHPExiftool\Exiftool::getBinary()
    APP/Vendor/PHPExiftool/Writer.php line 299 → PHPExiftool\Exiftool->executeCommand(string, integer)
    APP/Controller/AdminController.php line 429 → PHPExiftool\Writer->write(string, PHPExiftool\Driver\Metadata\MetadataBag)
    [internal function] → AdminController->imgdef()
    CORE/Cake/Controller/Controller.php line 499 → ReflectionMethod->invokeArgs(AdminController, array)
    CORE/Cake/Routing/Dispatcher.php line 193 → Controller->invokeAction(CakeRequest)
    CORE/Cake/Routing/Dispatcher.php line 167 → Dispatcher->_invoke(AdminController, CakeRequest)
    APP/webroot/index.php line 117 → Dispatcher->dispatch(CakeRequest, CakeResponse)

I have conformed at exiftool is located at:

root@sds n00002621 # where exiftool
/usr/local/bin/exiftool

Using macos 10.15.6, PHP 7.4.10, and CakePHP 2.10.22.

Any suggestions on how to fix this?

Stuart

How can I modify the existing tag or add a new tag

I am unable to find any code in which I can modify existing tags or add a new tag according to my own choice.

$bag = new MetadataBag();
$bag->add(new Metadata(new ObjectName(), new Mono('Pretty cool subject')));
$writer->write('1.eps', $bag);

This code assigns a random new tag.

I want to modify existing tag. Please help?

Dependency versions outdated

Hi,

some dependencies are outdated:

  • monolog/monolog: ^1.3 -> now available in version 2.0
  • symfony/console: ^2.1|^3.0 -> now available in version 4.3.5
  • symfony/process: ^2.1|^3.0 -> now available in version 4.3.5

In order to ensure maximum compatibility with other packages, it would be nice to have updated requirements (provided that the update doesn't break anything).

Thanks!

Unable to Install alchemy/phpexiftool Due to Missing Dependency

I hope this message finds you well. I encountered an issue while trying to install the alchemy/phpexiftool package via Composer. Here's the problem I encountered:

Problem 1

alchemy/phpexiftool version 4.0.0 and 4.0.1 require exiftool/exiftool with a version constraint of *, but it could not be found in any version. This suggests there may be a typo in the package name or an issue with the package repository.
Additionally, the root composer.json file of my project requires alchemy/phpexiftool with a version constraint of ^4.0, which should be satisfiable by versions 4.0.0 and 4.0.1 of alchemy/phpexiftool.

However, due to the missing exiftool/exiftool dependency, I'm unable to use the alchemy/phpexiftool package in my project as intended.

I kindly request your assistance in resolving this issue. If there is any additional information needed or if you require further clarification, please don't hesitate to reach out to me. Thank you for your time and support.

Unable to write RegistryEntryRole .JPG Metadata Tag

I am not able to write the RegistryEntryRole for the (JPG) image. I used below code snippet :

require __DIR__ . '/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;
use PHPExiftool\Driver\Tag\XMPIptcExt\RegistryEntryRole;

$logger = new Logger('exiftool');
$writer = Writer::create($logger);

$bag = new MetadataBag();
$bag->add(new Metadata(new RegistryEntryRole(), new Mono('New Value')));

$writer->write('test.jpg', $bag);

i checked the image metadata by both phpexiftool and getpmd.iptc.org, neither of them shows me RegistryEntryRole value.
Any suggestion why?
PHPEXIFTOOL: 0.7.3
Thank You.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.