You are here

private function SimpleExifToolFacade::runTool in Exif 8.2

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

Class

SimpleExifToolFacade
Class SimpleExifToolFacade.

Namespace

Drupal\exif

Code

private function runTool($file, $enable_sections = TRUE, $enable_markerNote = FALSE, $enable_non_supported_tags = FALSE) {
  $params = "";
  if ($enable_sections) {
    $params = "-g -struct ";
  }
  if ($enable_markerNote) {
    $params = $params . "-fast ";
  }
  else {
    $params = $params . "-fast2 ";
  }
  if ($enable_non_supported_tags) {
    $params = $params . " -u -U";
  }
  $commandline = self::getExecutable() . " -E -n -json " . $params . "\"" . $file . "\"";
  $output = [];
  $returnCode = 0;
  exec($commandline, $output, $returnCode);
  if ($returnCode != 0) {
    $output = "";
    Drupal::logger('exif')
      ->warning(t("exiftool return an error. can not extract metadata from file :file", [
      ':file' => $file,
    ]));
  }
  $info = implode("\n", $output);
  return $info;
}