Use Horde_Image_Exif library for this now
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 Aug 2009 17:56:52 +0000 (13:56 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 Aug 2009 17:56:52 +0000 (13:56 -0400)
ansel/lib/Ansel.php
ansel/lib/View/Image.php

index 8191217..48831f5 100644 (file)
@@ -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[] = '<td><strong>' . $description . '</strong></td><td>' . htmlspecialchars($value, ENT_COMPAT, Horde_Nls::getCharset()) . '</td>';
+            }
+        }
+
+        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.
index fef534f..b1f50f2 100644 (file)
@@ -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)) {