Ansel::isAvailable PHP Method

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.
    public static function isAvailable($feature)
    {
        static $capabilities;
        // If the administrator locked auto watermark on, disable user
        // intervention
        if ($feature == 'text_watermark' && $GLOBALS['prefs']->getValue('watermark_auto') && $GLOBALS['prefs']->isLocked('watermark_auto')) {
            return false;
        }
        if (!isset($capabilities)) {
            $im = Ansel::getImageObject();
            $capabilities = array_merge($im->getCapabilities(), $im->getLoadedEffects());
        }
        return in_array($feature, $capabilities);
    }

Usage Example

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();
     }
 }
All Usage Examples Of Ansel::isAvailable