isAvailable() public static method

Check to see if a particular image manipulation function is available.
public static isAvailable ( string $feature ) : boolean
$feature string The name of the function.
return boolean True if the function is available.
Example #1
0
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), true);
     /* Don't bother with these effects for a stack image
      * (which will have a negative gallery_id). */
     if ($this->_image->gallery > 0) {
         if (is_null($this->_style)) {
             $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery);
             $styleDef = $gal->getStyle();
         } else {
             $styleDef = $this->_style;
         }
         try {
             /* Apply the effects - continue on error, but be sure to log */
             $this->_image->addEffect('RoundCorners', array('border' => 2, 'bordercolor' => '#333'));
             $this->_image->addEffect('DropShadow', array('background' => $styleDef->background, 'padding' => 5, 'distance' => 5, 'fade' => 3));
             if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
                 $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
             }
             $this->_image->applyEffects();
         } catch (Horde_Image_Exception $e) {
             throw new Ansel_Exception($e);
         }
         return $this->_image->getHordeImage();
     }
 }
Example #2
0
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     // Take the largest requested dimension
     if (empty($this->_params['width'])) {
         $size = min($GLOBALS['conf']['thumbnail']['height'], $GLOBALS['conf']['thumbnail']['width']);
     } else {
         $size = min($this->_params['width'], $this->_params['height']);
     }
     // Use smartcrop algorithm if we have it, otherwise a plain center crop.
     if (Ansel::isAvailable('SmartCrop') && $GLOBALS['conf']['image']['smartcrop']) {
         $this->_image->addEffect('SmartCrop', array('width' => $size, 'height' => $size));
     } else {
         $this->_image->addEffect('CenterCrop', array('width' => $size, 'height' => $size));
     }
     $this->_image->applyEffects();
     if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
         try {
             $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
             $this->_image->applyEffects();
         } catch (Horde_Image_Exception $e) {
             throw new Ansel_Exception($e);
         }
     }
     return $this->_image->getHordeImage();
 }
Example #3
0
 /**
  *
  * @return boolean
  */
 protected function _create()
 {
     $this->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']), min($GLOBALS['conf']['screen']['height'], $this->_dimensions['height']), true);
     if ($GLOBALS['conf']['screen']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
         try {
             $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['screen']['radius'], 'threshold' => $GLOBALS['conf']['screen']['threshold'], 'amount' => $GLOBALS['conf']['screen']['amount']));
             $this->_image->applyEffects();
         } catch (Horde_Image $e) {
             throw new Ansel_Exception($e);
         }
     }
     return $this->_image->getHordeImage();
 }
Example #4
0
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     if ($GLOBALS['conf']['image']['squaremini']) {
         $generator = Ansel_ImageGenerator::factory('SquareThumb', array('width' => min(50, $this->_dimensions['width']), 'height' => min(50, $this->_dimensions['height']), 'image' => $this->_image, 'style' => $this->_params['style']));
         return $generator->create();
     } else {
         $this->_image->resize(min(50, $this->_dimensions['width']), min(50, $this->_dimensions['height']), true);
         if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
             try {
                 $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
                 $this->_image->applyEffects();
             } catch (Horde_Image_Exception $e) {
                 throw new Ansel_Exception($e);
             }
         }
         return $this->_image->getHordeImage();
     }
 }
Example #5
0
 /**
  *
  * @return Horde_Image
  */
 protected function _create()
 {
     $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']), min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']), true);
     /* Don't bother with these effects for a custom gallery key image
        (which will have a negative gallery_id). */
     if ($this->_image->gallery > 0) {
         if (is_null($this->_style)) {
             $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery);
             $styleDef = $gal->getStyle();
         } else {
             $styleDef = $this->_style;
         }
         try {
             $this->_image->addEffect('PolaroidImage', array('background' => $styleDef->background, 'padding' => 5));
             if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
                 $this->_image->addEffect('Unsharpmask', array('radius' => $GLOBALS['conf']['thumbnail']['radius'], 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'], 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
             }
             $this->_image->applyEffects();
         } catch (Horde_Image_Exception $e) {
             throw new Ansel_Exception($e);
         }
         return true;
     }
 }
Example #6
0
 /**
  * Horde_ImageGenerator factory
  *
  * @param string $type   The type of concrete instance to return.
  * @param array $params  Additional parameters needed for the instance.
  *
  * @return Ansel_ImageGenerator
  * @throws Ansel_Exception
  */
 public static function factory($type, $params = array())
 {
     $type = basename($type);
     $class = 'Ansel_ImageGenerator_' . $type;
     if (class_exists($class)) {
         $view = new $class($params);
         // Check that the image object supports what we need for the effect.
         foreach ($view->need as $need) {
             if (!Ansel::isAvailable($need)) {
                 $err = sprintf(_("This install does not support the %s feature. Please contact your administrator."), $need);
                 Horde::log($err, 'ERR');
                 throw new Ansel_Exception($err);
             }
         }
         return $view;
     } else {
         $err = sprintf(_("Unable to load the definition of %s."), $class);
         Horde::log($err, 'ERR');
         throw new Ansel_Exception($err);
     }
 }