You are here

public function ExifPHPExtension::readExifTags in Exif 7

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

Read the Information from a picture according to the fields specified in CCK

Parameters

$file:

$enable_sections:

Return value

array

1 call to ExifPHPExtension::readExifTags()
ExifPHPExtension::readMetadataTags in ./ExifPHPExtension.php
$arOptions liste of options for the method : # enable_sections : (default : TRUE) retrieve also sections.

File

./ExifPHPExtension.php, line 309

Class

ExifPHPExtension

Namespace

Drupal\exif

Code

public function readExifTags($file, $enable_sections = TRUE) {
  $ar_supported_types = array(
    'jpg',
    'jpeg',
  );
  if (!in_array(strtolower($this
    ->getFileType($file)), $ar_supported_types)) {
    return array();
  }
  $exif = array();
  try {
    $exif = @exif_read_data($file, 0, $enable_sections);
  } catch (Exception $e) {
    watchdog('exif', 'Error while reading EXIF tags from image: !message', array(
      '!message' => $e
        ->getMessage(),
    ), WATCHDOG_WARNING);
  }
  $arSmallExif = array();
  foreach ((array) $exif as $key1 => $value1) {
    if (is_array($value1)) {
      $value2 = array();
      foreach ((array) $value1 as $key3 => $value3) {
        $value[strtolower($key3)] = $value3;
      }
    }
    else {
      $value = $value1;
    }
    $arSmallExif[strtolower($key1)] = $value;
  }
  return $arSmallExif;
}