/**
* @var Horde_Image_Base Horde_Image object for this image.
*/
- public $_image;
+ protected $_image;
protected $_dirty;
protected $_loaded = array();
protected $_data = array();
}
/**
+ * Obtain a reference to the underlying Horde_Image
+ *
+ * @return Horde_Image_Base
+ */
+ public function &getHordeImage()
+ {
+ return $this->_image;
+ }
+
+ /**
* Return the vfs path for this image.
*
* @param string $view The view we want.
}
/**
+ * Resize the current image. This operation takes place immediately.
+ *
+ * @param integer $width The new width.
+ * @param integer $height The new height.
+ * @param boolean $ratio Maintain original aspect ratio.
+ * @param boolean $keepProfile Keep the image meta data.
+ *
+ * @return void
+ */
+ public function resize($width, $height, $ratio = true, $keepProfile = false)
+ {
+ $this->_image->resize($width, $height, $ratio, $keepProfile);
+ }
+
+ /**
* Converts the image to grayscale.
*
* @param string $view The view (size) to work with.
}
/**
+ * Add an effect to the effect stack
+ *
+ * @param string $type The effect to add.
+ * @param array $params The effect parameters.
+ *
+ * @return mixed
+ */
+ function addEffect($type, $params = array())
+ {
+ return $this->_image->addEffect($type, $params);
+ }
+
+ /**
+ * Apply any pending effects to the underlaying Horde_Image
+ *
+ * @return void
+ */
+ public function applyEffects()
+ {
+ $this->_image->applyEffects();
+ }
+
+ /**
* Returns this image's tags.
*
* @return mixed An array of tags | PEAR_Error
function create()
{
if (!empty($this->_image)) {
- $this->_dimensions = $this->_image->_image->getDimensions();
+ // Use Horde_Image since we don't know at this point which
+ // view we have loaded.
+ $img = $this->_image->getHordeImage();
+ $this->_dimensions = $img->getDimensions();
}
return $this->_create();
* Utility function to return an array of Ansel_Images to use
* in building a polaroid stack. Returns a random set of 5 images from
* the gallery, or the explicitly set default image plus 4 others.
+ *
+ * @return array of Horde_Images
*/
function _getStackImages()
{
$default = $gallery->get('default');
if (!empty($default) && $default > 0) {
try {
- $img = &$gallery->getImage($default);
- $images[] = &$gallery->getImage($default);
+ $img = $gallery->getImage($default);
+ $img->load('screen');
+ $images[] = $img->getHordeImage();//&$gallery->getImage($default);
$cnt--;
} catch (Horde_Exception $e) {}
}
$rnd = mt_rand(0, $cnt);
try {
$temp = $gallery->getImages($rnd, 1);
- $images[] = array_shift($temp);
+ $aimg = array_shift($temp);
+ $aimg->load('screen');
+ $images[] = $aimg->getHordeImage();
} catch (Horde_Exception $e) {}
}
function _create()
{
- $this->_image->_image->resize(min(50, $this->_dimensions['width']),
+ $this->_image->resize(min(50, $this->_dimensions['width']),
min(50, $this->_dimensions['height']),
true);
function _create()
{
- $imgobjs = array();
- $images = $this->_getStackImages();
+ $imgobjs = $this->_getStackImages();
$style = $this->_params['style'];
- foreach ($images as $image) {
- $result = $image->load('screen');
- $imgobjs[] = $image->_image;
- }
-
$params = array('width' => 100,
'height' => 100,
'background' => $style['background']);
function _create()
{
- $imgobjs = array();
- $images = $this->_getStackImages();
+ $imgobjs = $this->_getStackImages();
$style = $this->_params['style'];
- foreach ($images as $image) {
- $image->load('screen');
- $imgobjs[] = $image->_image;
- }
-
$params = array('width' => 100,
'height' => 100,
'background' => $style['background']);
function _create()
{
- $this->_image->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
- true);
+ $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 default image
(which will have a negative gallery_id). */
$styleDef = Ansel::getStyleDefinition($this->_style);
}
try {
- $this->_image->_image->addEffect('PolaroidImage',
- array('background' => $styleDef['background'],
- 'padding' => 5));
+ $this->_image->addEffect('PolaroidImage',
+ array('background' => $styleDef['background'],
+ 'padding' => 5));
- $this->_image->_image->applyEffects();
+ $this->_image->applyEffects();
} catch (Horde_Image_Exception $e) {
return false;
}
function _create()
{
- $this->_image->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
- true);
+ $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). */
try {
/* Apply the effects - continue on error, but be sure to log */
- $this->_image->_image->addEffect('RoundCorners', array('border' => 2,
- 'bordercolor' => '#333'));
+ $this->_image->addEffect('RoundCorners', array('border' => 2,
+ 'bordercolor' => '#333'));
- $this->_image->_image->addEffect('DropShadow', array('background' => $styleDef['background'],
- 'padding' => 5,
- 'distance' => 5,
- 'fade' => 3));
+ $this->_image->addEffect('DropShadow', array('background' => $styleDef['background'],
+ 'padding' => 5,
+ 'distance' => 5,
+ 'fade' => 3));
} catch (Horde_Image_Exception $e) {
return false;
}
+ $this->_image->applyEffects();
- return $this->_image->_image->applyEffects();
+ return true;
}
}
function _create()
{
- $imgobjs = array();
- $images = $this->_getStackImages();
+ $imgobjs = $this->_getStackImages();
$style = $this->_params['style'];
- foreach ($images as $image) {
- $result = $image->load('screen');
- $imgobjs[] = $image->_image;
- }
-
$params = array('width' => 100,
'height' => 100,
'background' => $style['background']);
function _create()
{
- $this->_image->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']),
+ $this->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']),
min($GLOBALS['conf']['screen']['height'], $this->_dimensions['height']),
true);
function _create()
{
- $this->_image->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
- true);
+ $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). */
}
try {
- $this->_image->_image->addEffect('border', array('bordercolor' => '#333'));
- $this->_image->_image->addEffect('DropShadow',
- array('background' => $styleDef['background'],
- 'padding' => 5,
- 'distance' => '8',
- 'fade' => 2));
- $this->_image->_image->applyEffects();
+ $this->_image->addEffect('border', array('bordercolor' => '#333'));
+ $this->_image->addEffect('DropShadow',
+ array('background' => $styleDef['background'],
+ 'padding' => 5,
+ 'distance' => '8',
+ 'fade' => 2));
+ $this->_image->applyEffects();
} catch (Horde_Image_Exception $e) {
return false;
}
function _create()
{
- $this->_image->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
- true);
-
+ $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
+ min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
+ true);
return true;
}