You are here

public function ExifPHPExtension::readIPTCTags in Exif 7

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

Read IPTC tags.

Parameters

String $file Path to image to read IPTC from:

boolean $enable_sections:

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

File

./ExifPHPExtension.php, line 351

Class

ExifPHPExtension

Namespace

Drupal\exif

Code

public function readIPTCTags($file, $enable_sections) {
  $humanReadableKey = $this
    ->getHumanReadableIPTCkey();
  $infoImage = array();
  $size = GetImageSize($file, $infoImage);
  $iptc = empty($infoImage["APP13"]) ? array() : iptcparse($infoImage["APP13"]);
  $arSmallIPTC = array();
  if (is_array($iptc)) {
    foreach ($iptc as $key => $value) {
      if (count($value) == 1) {
        $resultTag = $value[0];
      }
      else {
        $resultTag = $value;
      }
      if (array_key_exists($key, $humanReadableKey)) {
        $humanKey = $humanReadableKey[$key];
        $arSmallIPTC[$humanKey] = $resultTag;
      }
      else {
        $arSmallIPTC[$key] = $resultTag;
      }
    }
  }
  if ($enable_sections) {
    return array(
      'iptc' => $arSmallIPTC,
    );
  }
  else {
    return $arSmallIPTC;
  }
}