Track changes in Horde_Image
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 2 Aug 2009 20:12:13 +0000 (16:12 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 2 Aug 2009 20:12:13 +0000 (16:12 -0400)
imp/lib/Mime/Viewer/Images.php
imp/lib/Mime/Viewer/Pdf.php
news/lib/News.php

index 6df5b9d..b1929a6 100644 (file)
@@ -253,20 +253,25 @@ EOD;
         $img = null;
         //@TODO: Pass in a Horde_Logger in $context if desired.
         $context = array('tmpdir' => Horde::getTempDir());
-        if (!empty($GLOBALS['conf']['image']['convert'])) {
-            $context['convert'] = $GLOBALS['conf']['image']['convert'];
-            $img = Horde_Image::factory('Im', array('context' => $context));
-        } elseif (Horde_Util::extensionExists('gd')) {
-            $img = Horde_Image::factory('Gd', array('context' => $context));
+        try {
+            if (!empty($GLOBALS['conf']['image']['convert'])) {
+                $context['convert'] = $GLOBALS['conf']['image']['convert'];
+                $img = Horde_Image::factory('Im', array('context' => $context));
+            } elseif (Horde_Util::extensionExists('gd')) {
+                $img = Horde_Image::factory('Gd', array('context' => $context));
+            }
+        } catch (Horde_Image_Exception $e) {
+            return false;
         }
 
-        if (!$img || ($img instanceof PEAR_Error)) {
+        if (!$img) {
             return false;
         }
 
         if ($load) {
-            $ret = $img->loadString(1, $this->_mimepart->getContents());
-            if ($ret instanceof PEAR_Error) {
+            try {
+                $ret = $img->loadString(1, $this->_mimepart->getContents());
+            } catch (Horde_Image_Exception $e) {
                 return false;
             }
         }
index 8ec5a7c..5a51213 100644 (file)
@@ -114,15 +114,16 @@ class IMP_Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf
             return false;
         }
 
-        $img = Horde_Image::factory('Im', array('context' => array('tmpdir' => Horde::getTempdir(),
-                                                                   'convert' => $GLOBALS['conf']['image']['convert'])));
-        if ($img instanceof PEAR_Error) {
+        try {
+            $img = Horde_Image::factory('Im', array('context' => array('tmpdir' => Horde::getTempdir(),
+                                                                       'convert'=> $GLOBALS['conf']['image']['convert'])));
+        } catch (Horde_Image_Exception $e) {
             return false;
         }
-
         if ($load) {
-            $ret = $img->loadString(1, $this->_mimepart->getContents());
-            if ($ret instanceof PEAR_Error) {
+            try {
+                $ret = $img->loadString(1, $this->_mimepart->getContents());
+            } catch (Horde_Image_Exception $e) {
                 return false;
             }
         }
index ed7a66e..b1092f2 100644 (file)
@@ -271,15 +271,7 @@ class News {
                         'context' => $context);
         $driver = empty($conf['image']['convert']) ? 'Gd' : 'Im';
         $img = Horde_Image::factory($driver, $params);
-
-        if ($img instanceof PEAR_Error) {
-            return $img;
-        }
-
         $result = $img->loadFile($file);
-        if ($result instanceof PEAR_Error) {
-            return $result;
-        }
 
         // Store big image for articles
         if ($type == 'news') {