Overview

Packages

  • Image
  • None

Classes

  • Horde_Image
  • Horde_Image_Base
  • Horde_Image_Effect
  • Horde_Image_Effect_Border
  • Horde_Image_Effect_Gd_DropShadow
  • Horde_Image_Effect_Gd_RoundCorners
  • Horde_Image_Effect_Gd_TextWatermark
  • Horde_Image_Effect_Gd_Unsharpmask
  • Horde_Image_Effect_Im_Border
  • Horde_Image_Effect_Im_CenterCrop
  • Horde_Image_Effect_Im_Composite
  • Horde_Image_Effect_Im_DropShadow
  • Horde_Image_Effect_Im_LiquidResize
  • Horde_Image_Effect_Im_PhotoStack
  • Horde_Image_Effect_Im_PolaroidImage
  • Horde_Image_Effect_Im_RoundCorners
  • Horde_Image_Effect_Im_TextWatermark
  • Horde_Image_Effect_Im_Unsharpmask
  • Horde_Image_Effect_Imagick_Border
  • Horde_Image_Effect_Imagick_CenterCrop
  • Horde_Image_Effect_Imagick_Composite
  • Horde_Image_Effect_Imagick_DropShadow
  • Horde_Image_Effect_Imagick_LiquidResize
  • Horde_Image_Effect_Imagick_PhotoStack
  • Horde_Image_Effect_Imagick_PolaroidImage
  • Horde_Image_Effect_Imagick_RoundCorners
  • Horde_Image_Effect_Imagick_SmartCrop
  • Horde_Image_Effect_Imagick_TextWatermark
  • Horde_Image_Effect_Imagick_Unsharpmask
  • Horde_Image_Exception
  • Horde_Image_Exif
  • Horde_Image_Exif_Base
  • Horde_Image_Exif_Bundled
  • Horde_Image_Exif_Exiftool
  • Horde_Image_Exif_Parser_Base
  • Horde_Image_Exif_Php
  • Horde_Image_Gd
  • Horde_Image_Im
  • Horde_Image_Imagick
  • Horde_Image_Png
  • Horde_Image_Svg
  • Horde_Image_Swf
  • Horde_Image_Translation
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Exiftool driver for reading/writing image meta data
 4:  *
 5:  * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file COPYING for license information (LGPL). If you
 8:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 9:  *
10:  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
11:  * @package Image
12:  */
13: class Horde_Image_Exif_Exiftool extends Horde_Image_Exif_Base
14: {
15:     /**
16:      * Path to exiftool binary
17:      *
18:      * @var string
19:      */
20:     protected $_exiftool;
21: 
22:     public function __construct($params)
23:     {
24:         parent::__construct($params);
25:         if (empty($this->_params['exiftool'])) {
26:             throw new InvalidArgumentException('Missing required exiftool path');
27:         }
28:         $this->_exiftool = $this->_params['exiftool'];
29:     }
30: 
31:     /**
32:      * Get the image's EXIF data.
33:      *
34:      * @param string $image  The path to an image.
35:      *
36:      * @return array  The exif data.
37:      */
38:     public function getData($image)
39:     {
40:         // Request the full stream of meta data in JSON format.
41:         // -j option outputs in JSON, appending '#' to the -TAG prevents
42:         // screen formatting.
43:         $categories = Horde_Image_Exif::getCategories();
44:         $tags = '';
45:         foreach (array('EXIF', 'IPTC', 'XMP') as $category) {
46:             foreach ($categories[$category] as $field => $value) {
47:                 $tags .= ' -' . $field . '#';
48:             }
49:         }
50:         foreach ($categories['COMPOSITE'] as $field => $value) {
51:             $tags .= ' -' . $field;
52:         }
53:         $command = '-j' . $tags . ' ' . $image;
54:         $results = json_decode($this->_execute($command));
55:         if (is_array($results)) {
56:             return $this->_processData((array)array_pop($results));
57:         }
58: 
59:         throw new Horde_Image_Exception('Unknown error running exiftool command');
60:     }
61: 
62:     public function supportedCategories()
63:     {
64:         return array('EXIF', 'IPTC', 'XMP', 'COMPOSITE');
65:     }
66: 
67:     /**
68:      * Executes a exiftool command.
69:      *
70:      * @param string $command  The command to run
71:      *
72:      * @return mixed  The result of the command.
73:      */
74:     protected function _execute($command)
75:     {
76:         $output = array();
77:         $retval = null;
78:         exec($this->_exiftool . ' ' . escapeshellcmd($command), $output, $retval);
79:         if ($retval) {
80:             $this->_logErr(sprintf("Error running command: %s", $command . "\n" . implode("\n", $output)));
81:         }
82:         if (is_array($output)) {
83:             $output = implode('', $output);
84:         }
85: 
86:         return $output;
87:     }
88: 
89: }
API documentation generated by ApiGen