You are here

private function SimpleExifToolFacade::readAllInformation in Exif 8

Same name and namespace in other branches
  1. 8.2 src/SimpleExifToolFacade.php \Drupal\exif\SimpleExifToolFacade::readAllInformation()
  2. 7 SimpleExiftoolFacade.php \Drupal\exif\SimpleExifToolFacade::readAllInformation()

Retrieve all metadata using exifTool.

Parameters

string $file: Image to scan.

bool $enable_sections: Extract sections or not.

bool $enable_markerNote: Extract marker notes or not (for now, always FALSE)

bool $enable_non_supported_tags: Extract non supported tags or not (for now, always FALSE)

Return value

array all metadata usable by this module.

1 call to SimpleExifToolFacade::readAllInformation()
SimpleExifToolFacade::readMetadataTags in src/SimpleExifToolFacade.php
Retrieve all metadata from a file.

File

src/SimpleExifToolFacade.php, line 102

Class

SimpleExifToolFacade
Class SimpleExifToolFacade.

Namespace

Drupal\exif

Code

private 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.
    \Drupal::logger('exif')
      ->notice(t($errorMessage));
    return [];
  }
}