From ec973036c5245cc47250a6c9d217192204ebb8e8 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sun, 2 Aug 2009 16:12:13 -0400 Subject: [PATCH] Track changes in Horde_Image --- imp/lib/Mime/Viewer/Images.php | 21 +++++++++++++-------- imp/lib/Mime/Viewer/Pdf.php | 13 +++++++------ news/lib/News.php | 8 -------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/imp/lib/Mime/Viewer/Images.php b/imp/lib/Mime/Viewer/Images.php index 6df5b9d3e..b1929a66d 100644 --- a/imp/lib/Mime/Viewer/Images.php +++ b/imp/lib/Mime/Viewer/Images.php @@ -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; } } diff --git a/imp/lib/Mime/Viewer/Pdf.php b/imp/lib/Mime/Viewer/Pdf.php index 8ec5a7c68..5a51213e4 100644 --- a/imp/lib/Mime/Viewer/Pdf.php +++ b/imp/lib/Mime/Viewer/Pdf.php @@ -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; } } diff --git a/news/lib/News.php b/news/lib/News.php index ed7a66e94..b1092f284 100644 --- a/news/lib/News.php +++ b/news/lib/News.php @@ -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') { -- 2.11.0