Same name in other branches
  1. 7.x-1.x SimpleExiftoolFacade.php \Drupal\exif\SimpleExifToolFacade::runTool()
  2. 8.x-1.x src/SimpleExifToolFacade.php \Drupal\exif\SimpleExifToolFacade::runTool()

Handle how to call 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

string ExifTool JSON result containing all metadata.

1 call to SimpleExifToolFacade::runTool()
SimpleExifToolFacade::readAllInformation in src/SimpleExifToolFacade.php
Retrieve all metadata using exifTool.

File

src/SimpleExifToolFacade.php, line 159

Class

SimpleExifToolFacade
Class SimpleExifToolFacade.

Namespace

Drupal\exif

Code

private function runTool($file, $enable_sections = TRUE, $enable_markerNote = FALSE, $enable_non_supported_tags = FALSE) {
    $params = ' -E -n -json ';
    if ($enable_sections) {
        $params .= '-g -struct ';
    }
    if ($enable_markerNote) {
        $params .= '-fast ';
    }
    else {
        $params .= '-fast2 ';
    }
    if ($enable_non_supported_tags) {
        $params .= '-u -U ';
    }
    // Escape all of the arguments passed to the function.
    // Note: If params is expanded so it is customizable, make sure that each
    // piece is passed through escapeshellarg().
    $commandline = escapeshellcmd(self::getExecutable() . $params . escapeshellarg($file));
    $output = [];
    $returnCode = 0;
    exec($commandline, $output, $returnCode);
    if ($returnCode != 0) {
        $output = "";
        \Drupal::logger('exif')->warning($this->t("exiftool return an error. can not extract metadata from file :file", [
            ':file' => $file,
        ]));
    }
    $info = implode("\n", $output);
    return $info;
}