public function Exif::readExifTags in Exif 6
Read the Information from a picture according to the fields specified in CCK
Parameters
$file:
$arTagNames:
Return value
array
File
- ./
exif.class.php, line 59
Class
- Exif
- @author Raphael Schär This is a helper class to handle the whole data processing of exif
Code
public function readExifTags($file, $arTagNames = array()) {
if (!file_exists($file)) {
return array();
}
$ar_supported_types = array(
'jpg',
'jpeg',
);
if (!in_array(strtolower($this
->getFileType($file)), $ar_supported_types)) {
return array();
}
$exif = exif_read_data($file, 0);
$arSmallExif = array();
$arSmallExif = array_change_key_case((array) $exif, CASE_LOWER);
$arSmallExif['computed'] = array_change_key_case((array) $arSmallExif['computed'], CASE_LOWER);
//why this function isn't recursive is beyond me
$arSmallExif['thumbnail'] = array_change_key_case((array) $arSmallExif['thumbnail'], CASE_LOWER);
$arSmallExif['comment'] = array_change_key_case((array) $arSmallExif['comment'], CASE_LOWER);
$info = array();
foreach ($arTagNames as $tagName) {
if ($tagName['section'] != 'iptc') {
if (!empty($arSmallExif[$tagName['tag']])) {
$info[$tagName['section'] . '_' . $tagName['tag']] = utf8_encode($arSmallExif[$tagName['tag']]);
}
elseif (!empty($arSmallExif[$tagName['section']][$tagName['tag']])) {
$info[$tagName['section'] . '_' . $tagName['tag']] = utf8_encode($arSmallExif[$tagName['section']][$tagName['tag']]);
}
}
}
return $info;
}