You are here

function SimpleExifToolFacade::readAllInformation in Exif 7

Same name and namespace in other branches
  1. 8.2 src/SimpleExifToolFacade.php \Drupal\exif\SimpleExifToolFacade::readAllInformation()
  2. 8 src/SimpleExifToolFacade.php \Drupal\exif\SimpleExifToolFacade::readAllInformation()
1 call to SimpleExifToolFacade::readAllInformation()
SimpleExifToolFacade::readMetadataTags in ./SimpleExiftoolFacade.php
$arOptions liste of options for the method : # enable_sections : (default : TRUE) retrieve also sections.

File

./SimpleExiftoolFacade.php, line 134

Class

SimpleExifToolFacade

Namespace

Drupal\exif

Code

function readAllInformation($file, $enable_sections = true, $enable_markerNote = false, $enable_non_supported_tags = false) {
  $jsonAsString = $this
    ->runTool($file, $enable_sections, $enable_markerNote, $enable_non_supported_tags);
  $json = json_decode($jsonAsString, true);
  $errorCode = json_last_error();
  if ($errorCode == JSON_ERROR_NONE) {
    return $this
      ->tolowerJsonResult($json[0]);
  }
  else {
    $errorMessage = "";
    switch ($errorCode) {
      case JSON_ERROR_DEPTH:
        $errorMessage = 'Maximum stack depth exceeded';
        break;
      case JSON_ERROR_STATE_MISMATCH:
        $errorMessage = 'Underflow or the modes mismatch';
        break;
      case JSON_ERROR_CTRL_CHAR:
        $errorMessage = 'Unexpected control character found';
        break;
      case JSON_ERROR_SYNTAX:
        $errorMessage = 'Syntax error, malformed JSON';
        break;
      case JSON_ERROR_UTF8:
        $errorMessage = 'Malformed UTF-8 characters, possibly incorrectly encoded';
        break;
      default:
        $errorMessage = 'Unknown error';
        break;
    }

    // Logs a notice
    watchdog('exif', 'Error reading information from exiftool for file !file: !message', array(
      '!file' => $file,
      '!message' => $errorMessage,
    ), WATCHDOG_NOTICE);
    return array();
  }
}