Public Member Functions | |
| __construct ($exiftool= '/usr/bin/exiftool', $format=self::FORMAT_JSON) | |
| getExifs ($file, $format=null) | |
| Returns exifs of an image. | |
| getExiftool () | |
| getFormat () | |
| setExiftool ($exiftool) | |
| Set Exiftool. | |
| setFormat ($format) | |
Public Attributes | |
| const | FORMAT_ARRAY = 'array' |
| Format ARRAY. | |
| const | FORMAT_JSON = 'json' |
| Format JSON. | |
| const | FORMAT_XML = 'xml' |
| Format XML. | |
Protected Member Functions | |
| _runExiftool ($file, $format) | |
Protected Attributes | |
| $_exiftool = '/usr/bin/exiftool' | |
| $_format = null | |
Definition at line 34 of file Exiftool.php.
| Robo47_Exiftool::__construct | ( | $ | exiftool = '/usr/bin/exiftool', |
|
| $ | format = self::FORMAT_JSON | |||
| ) |
| string | $exiftool |
Definition at line 67 of file Exiftool.php.
References setExiftool(), and setFormat().
{
$this->setExiftool($exiftool);
$this->setFormat($format);
}

| Robo47_Exiftool::_runExiftool | ( | $ | file, | |
| $ | format | |||
| ) | [protected] |
| string | $file | |
| string | $format |
| Robo47_Exiftool_Exception |
Definition at line 163 of file Exiftool.php.
Referenced by getExifs().
{
$command = escapeshellarg($this->_exiftool);
switch ($format) {
case self::FORMAT_JSON:
$command .= ' -j ';
break;
case self::FORMAT_XML:
$command .= ' -X ';
break;
}
$output = array();
$command .= ' ' . escapeshellarg($file);
$command .= ' 2>&1 ';
$returnCode = 0;
exec($command, $output, $returnCode);
if ($returnCode != 0) {
$message = 'executing exiftool failed: ' . implode('', $output);
$message .= PHP_EOL . 'command: ' . $command;
throw new Robo47_Exiftool_Exception($message, $returnCode);
}
return implode('', $output);
}

| Robo47_Exiftool::getExifs | ( | $ | file, | |
| $ | format = null | |||
| ) |
Returns exifs of an image.
| string | $file | |
| string | $format Valid formats are xml, json, array, dom |
| Robo47_Exiftool_Exception |
Definition at line 133 of file Exiftool.php.
References _runExiftool(), and getFormat().
{
if (!file_exists($file) || !is_file($file)) {
$message = 'File "' . $file . '" does not exist.';
throw new Robo47_Exiftool_Exception($message);
}
if (null === $format) {
$format = $this->getFormat();
}
switch ($format) {
case self::FORMAT_JSON:
$exifs = $this->_runExiftool($file, self::FORMAT_JSON);
break;
case self::FORMAT_ARRAY:
$exifs = $this->_runExiftool($file, self::FORMAT_JSON);
$exifs = json_decode($exifs, true);
break;
case self::FORMAT_XML:
$exifs = $this->_runExiftool($file, self::FORMAT_XML);
break;
}
return $exifs;
}

| Robo47_Exiftool::getExiftool | ( | ) |
| Robo47_Exiftool::getFormat | ( | ) |
Definition at line 120 of file Exiftool.php.
Referenced by getExifs().
{
return $this->_format;
}

| Robo47_Exiftool::setExiftool | ( | $ | exiftool | ) |
Set Exiftool.
| string | $exiftool |
Definition at line 80 of file Exiftool.php.
Referenced by __construct().
{
$this->_exiftool = $exiftool;
return $this;
}

| Robo47_Exiftool::setFormat | ( | $ | format | ) |
| string | $format |
Definition at line 100 of file Exiftool.php.
Referenced by __construct().
{
$format = strtolower($format);
switch ($format) {
case self::FORMAT_JSON:
case self::FORMAT_ARRAY:
case self::FORMAT_XML:
break;
default:
$message = 'Invalid format: ' . $format;
throw new Robo47_Exiftool_Exception($message);
}
$this->_format = $format;
return $this;
}

Robo47_Exiftool::$_exiftool = '/usr/bin/exiftool' [protected] |
Definition at line 61 of file Exiftool.php.
Robo47_Exiftool::$_format = null [protected] |
Definition at line 55 of file Exiftool.php.
| const Robo47_Exiftool::FORMAT_ARRAY = 'array' |
Format ARRAY.
Definition at line 39 of file Exiftool.php.
| const Robo47_Exiftool::FORMAT_JSON = 'json' |
Format JSON.
Definition at line 49 of file Exiftool.php.
| const Robo47_Exiftool::FORMAT_XML = 'xml' |
Format XML.
Definition at line 44 of file Exiftool.php.
1.7.1