* @author Georg Rehfeld * @version $Revision: 17580 $ */ class ExifExtractor extends ExifInterface_1_0 { /** * @see ExifInterface_1_0::getMetaData */ function getMetaData($itemIds, $properties=array()) { global $gallery; GalleryCoreApi::requireOnce('modules/exif/lib/exifer/exif.inc'); if (!is_array($itemIds)) { $itemIds = array($itemIds); } if (!is_array($properties)) { $properties = array($properties); } $data = array(); foreach ($itemIds as $itemId) { list ($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId, 'GalleryItem'); if ($ret) { return array($ret, null); } /* Only look at JPEG/raw DataItems.. */ if (!GalleryUtilities::isA($item, 'GalleryDataItem') || !preg_match('{^image/(p?jpeg(-cmyk)?|x-dcraw)$}', $item->getMimeType())) { continue; } list ($ret, $path) = $item->fetchPath(); if ($ret) { return array($ret, null); } $data[$itemId] = array(); $rawExifData = read_exif_data_raw($path, false); GalleryCoreApi::requireOnce('modules/exif/classes/ExifHelper.class'); list ($ret, $iptcObj) = ExifHelper::getIptcObject($path); if ($ret) { return array($ret, null); } foreach (ExifHelper::getExifKeys() as $property => $keyData) { if (!empty($properties) && !in_array($property, $properties)) { continue; } for ($i = 1; $i < count($keyData); $i++) { $value = ExifHelper::getExifValue($rawExifData, explode('.', $keyData[$i])); if (!isset($value)) { $value = ExifHelper::getIptcValue($iptcObj, explode('.', $keyData[$i])); } if (isset($value)) { $value = ExifHelper::postProcessValue($property, $value); $data[$itemId][$property] = array('title' => $keyData[0], 'value' => $value); break; } } } } return array(null, $data); } } ?>