$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;
}
}
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;
}
}
'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') {