From: Michael J. Rubinsky Date: Sat, 1 Aug 2009 17:56:52 +0000 (-0400) Subject: Use Horde_Image_Exif library for this now X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=47e7be4396da99fe1454b65b0445f995bc7f08d8;p=horde.git Use Horde_Image_Exif library for this now --- diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index 81912179d..48831f52e 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -3012,6 +3012,39 @@ class Ansel_Image { return $view; } + /** + * Get the image attributes from the backend. + * + * @param Ansel_Image $image The image to retrieve attributes for. + * attributes for. + * @param boolean $format Format the EXIF data. If false, the raw data + * is returned. + * + * @return array The EXIF data. + * @static + */ + function getAttributes($format = false) + { + $attributes = $GLOBALS['ansel_storage']->getImageAttributes($this->id); + $fields = Horde_Image_Exif::getFields(); + $output = array(); + + foreach ($fields as $field => $data) { + if (!isset($attributes[$field])) { + continue; + } + $value = Horde_Image_Exif::getHumanReadable($field, Horde_String::convertCharset($attributes[$field], $GLOBALS['conf']['sql']['charset'])); + if (!$format) { + $output[$field] = $value; + } else { + $description = isset($data['description']) ? $data['description'] : $field; + $output[] = '' . $description . '' . htmlspecialchars($value, ENT_COMPAT, Horde_Nls::getCharset()) . ''; + } + } + + return $output; + } + } /** @@ -3925,6 +3958,17 @@ class Ansel_Storage { } /** + * Get image attribtues from ansel_image_attributes table + * + * @param $image_id + * @return unknown_type + */ + function getImageAttributes($image_id) + { + return $GLOBALS['ansel_db']->queryAll('SELECT attr_name, attr_value FROM ansel_image_attributes WHERE image_id = ' . (int)$image_id, null, MDB2_FETCHMODE_ASSOC, true); + } + + /** * Like getRecentImages, but returns geotag data for the most recently added * images from the current user. Useful for providing images to help locate * images at the same place. diff --git a/ansel/lib/View/Image.php b/ansel/lib/View/Image.php index fef534fd2..b1f50f275 100644 --- a/ansel/lib/View/Image.php +++ b/ansel/lib/View/Image.php @@ -364,7 +364,7 @@ class Ansel_View_Image extends Ansel_View_Base */ private function _getExifHtml() { - $data = Ansel_ImageData::getAttributes($this->resource, true); + $data = $this->resource->getAttributes(true); $html = ''; if (count($data)) {