/usr/share/php/Horde/Image/Exif/Exiftool.php is in php-horde-image 2.5.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | <?php
/**
* Copyright 2009-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @category Horde
* @package Image
*/
/**
* Exiftool driver for reading/writing image meta data
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @category Horde
* @copyright 2009-2017 Horde LLC
* @package Image
*/
class Horde_Image_Exif_Exiftool extends Horde_Image_Exif_Base
{
/**
* Path to exiftool binary
*
* @var string
*/
protected $_exiftool;
public function __construct($params)
{
parent::__construct($params);
if (empty($this->_params['exiftool'])) {
throw new InvalidArgumentException('Missing required exiftool path');
}
$this->_exiftool = $this->_params['exiftool'];
}
/**
* Get the image's EXIF data.
*
* @param string $image The path to an image.
*
* @return array The exif data.
*/
public function getData($image)
{
// Request the full stream of meta data in JSON format.
// -j option outputs in JSON, appending '#' to the -TAG prevents
// screen formatting.
$categories = Horde_Image_Exif::getCategories();
$tags = '';
foreach (array('EXIF', 'IPTC', 'XMP') as $category) {
foreach ($categories[$category] as $field => $value) {
$tags .= ' -' . $field . '#';
}
}
foreach ($categories['COMPOSITE'] as $field => $value) {
$tags .= ' -' . $field;
}
$command = '-j' . $tags . ' ' . $image;
$this->_logDebug('Command executed by Exiftool: ' . $command);
$results = json_decode($this->_execute($command));
$this->_logDebug('Results of Exiftool command: ' . print_r($results, true));
if (is_array($results)) {
return $this->_processData((array)array_pop($results));
}
throw new Horde_Image_Exception('Unknown error running exiftool command');
}
public function supportedCategories()
{
return array('EXIF', 'IPTC', 'XMP', 'COMPOSITE');
}
/**
* Executes a exiftool command.
*
* @param string $command The command to run
*
* @return mixed The result of the command.
*/
protected function _execute($command)
{
$output = array();
$retval = null;
exec($this->_exiftool . ' ' . escapeshellcmd($command), $output, $retval);
if ($retval) {
$this->_logErr(sprintf("Error running command: %s", $command . "\n" . implode("\n", $output)));
}
if (is_array($output)) {
$output = implode('', $output);
}
return $output;
}
}
|