Same name and namespace in other branches
  1. 8.x-1.x src/SimpleExifToolFacade.php \Drupal\exif\SimpleExifToolFacade::readAllInformation() 1 comment
  2. 8.x-2.x src/SimpleExifToolFacade.php \Drupal\exif\SimpleExifToolFacade::readAllInformation() 1 comment
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 114

Class

SimpleExifToolFacade
Helper class to handle the whole data processing of EXIF with exiftool.

Namespace

Drupal\exif

Code

public 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();
    }
}