You are here

public function ExifPHPExtension::readMetadataTags in Exif 8

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

Read all metadata tags.

Parameters

string $file: Path to file.

bool $enable_sections: Indicate if the information is retrieve by sections or flatten.

Return value

array Values by key and optionally sections.

Overrides ExifInterface::readMetadataTags

File

src/ExifPHPExtension.php, line 127

Class

ExifPHPExtension
Class ExifPHPExtension Parser implementation base d on PHP Exif extension.

Namespace

Drupal\exif

Code

public function readMetadataTags($file, $enable_sections = TRUE) {
  if (!file_exists($file)) {
    return [];
  }
  $data1 = $this
    ->readExifTags($file, $enable_sections);
  $data2 = $this
    ->readIptcTags($file, $enable_sections);
  $data = array_merge($data1, $data2);
  if (is_array($data)) {
    foreach ($data as $section => $section_data) {
      $section_data = $this
        ->reformat($section_data);
      $data[$section] = $section_data;
    }
  }
  return $data;
}