You are here

public function Exif::readIPTCTags in Exif 6

Read IPTC tags.

Parameters

String $file: Path to image to read IPTC from

array $arTagNames: An array of Strings that contain the IPTC to read If you leave this empty nothing will be returned, unless you select a special return style in the $arOptions

array $arOptions: The following options are possible: style: fullSmall

File

./exif.class.php, line 113

Class

Exif
@author Raphael Schär This is a helper class to handle the whole data processing of exif

Code

public function readIPTCTags($file, $arTagNames = array(), $arOptions = array()) {
  $humanReadableKey = $this
    ->getHumanReadableIPTCkey();
  $size = GetImageSize($file, $infoImage);
  $iptc = empty($infoImage["APP13"]) ? array() : iptcparse($infoImage["APP13"]);
  $arSmallIPTC = array();
  if (is_array($iptc)) {
    foreach ($iptc as $key => $value) {
      $resultTag = "";
      foreach ($value as $innerkey => $innervalue) {
        if ($innerkey + 1 != count($value)) {
          $resultTag .= $innervalue . ", ";
        }
        else {
          $resultTag .= $innervalue;
        }
      }
      $arSmallIPTC[$humanReadableKey[$key]] = $resultTag;
    }
  }
  if ($arOptions['style'] == 'fullSmall') {
    return $arSmallIPTC;
  }
  $info = array();
  foreach ($arTagNames as $tagName) {
    if ($tagName['section'] == "iptc") {
      $info[$tagName['section'] . '_' . $tagName['tag']] = utf8_encode($arSmallIPTC[$tagName['tag']]);
    }
  }
  return $info;
}