From 42d960346aa6e9dabe75430c9cf1b293a101e4eb Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sat, 1 Aug 2009 12:16:57 -0400 Subject: [PATCH] Switch over to new Horde_Image_Exif code. Use new Horde_Image_Exif code, plus don't attempt to get exif data if we are creating a new galley key image...should save a few cycles when either switching to a new gallery style or adding new images when no key image is explicitly set. --- ansel/lib/Ansel.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index da72f3be5..81912179d 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -2458,8 +2458,10 @@ class Ansel_Image { /* The EXIF functions require a stream, so we need to save before we read */ $this->_writeData(); - /* Get the EXIF data now that we have an id and a file in the VFS */ - $needUpdate = $this->_getEXIF(); + /* Get the EXIF data if we are not a gallery key image. */ + if ($this->gallery > 0) { + $needUpdate = $this->_getEXIF(); + } /* Create tags from exif data if desired */ $fields = @unserialize($GLOBALS['prefs']->getValue('exif_tags')); @@ -2478,7 +2480,7 @@ class Ansel_Image { } /* Save again if EXIF changed any values */ - if ($needUpdate) { + if (!empty($needUpdate)) { $this->save(); } @@ -2540,13 +2542,17 @@ class Ansel_Image { */ function _getEXIF() { - require_once ANSEL_BASE . '/lib/Exif.php'; - /* Clear the local copy */ $this->_exif = array(); /* Get the data */ - $exif_fields = Ansel_ImageData::getExifData($this); + $imageFile = $GLOBALS['ansel_vfs']->readFile($this->getVFSPath('full'), + $this->getVFSName('full')); + if (is_a($imageFile, 'PEAR_Error')) { + return $imageFile; + } + $exif = Horde_Image_Exif::factory(); + $exif_fields = $exif->getData($imageFile); /* Flag to determine if we need to resave the image data */ $needUpdate = false; @@ -2577,7 +2583,7 @@ class Ansel_Image { return $result; } /* Cache it locally */ - $this->_exif[$name] = Ansel_ImageData::getHumanReadable($name, $value); + $this->_exif[$name] = Horde_Image_Exif::getHumanReadable($name, $value); } $insert->free(); } -- 2.11.0