*/
public function apply()
{
- Horde_Image_Imagick::borderImage($this->_image->imagick,
- $this->_params['bordercolor'],
- $this->_params['borderwidth'],
- $this->_params['borderwidth']);
+ if ($this->_params['preserve']) {
+ Horde_Image_Imagick::frameImage($this->_image->imagick,
+ $this->_params['bordercolor'],
+ $this->_params['borderwidth'],
+ $this->_params['borderwidth']);
+ } else {
+ $this->_image->imagick->borderImage(
+ new ImagickPixel($this->_params['bordercolor']),
+ $this->_params['borderwidth'],
+ $this->_params['borderwidth']);
+ }
+
return true;
}
$this->_params['distance'],
$this->_params['distance']);
-
- // If we have an actual background color, we need to explicitly
- // create a new background image with that color to be sure there
- // *is* a background color.
- if ($this->_params['background'] != 'none') {
- $size = $shadow->getImageGeometry();
- $new = new Imagick();
- $new->newImage($size['width'], $size['height'], new ImagickPixel($this->_params['background']));
- $new->setImageFormat($this->_image->getType());
-
- $new->compositeImage($shadow, Imagick::COMPOSITE_OVER, 0, 0);
- $shadow->clear();
- $shadow->addImage($new);
- $new->destroy();
- }
-
$shadow->compositeImage($this->_image->imagick, Imagick::COMPOSITE_OVER, 0, 0);
if ($this->_params['padding']) {
- Horde_Image_Imagick::borderImage($shadow,
- $this->_params['background'],
- $this->_params['padding'],
- $this->_params['padding']);
+ $shadow->borderImage($this->_params['background'],
+ $this->_params['padding'],
+ $this->_params['padding']);
}
$this->_image->imagick->clear();
$this->_image->imagick->addImage($shadow);
$imgk= new Imagick();
$imgk->clear();
$imgk->readImageBlob($image->raw());
+ // Either resize the thumbnail to match the top image or we *are*
+ // the top image already.
if ($i++ <= $cnt) {
- $imgk->thumbnailImage($size['width'], $size['height'],
- false);
+ $imgk->thumbnailImage($size['width'], $size['height'], false);
} else {
$imgk->destroy();
$imgk = $topimg->clone();
}
-
if ($this->_params['type'] == 'rounded') {
$imgk = $this->_roundBorder($imgk);
} else {
- Horde_Image_Imagick::borderImage($imgk,
- $this->_params['bordercolor'],
- $this->_params['borderwidth'],
- $this->_params['borderwidth']);
+ $imgk->borderImage($this->_params['bordercolor'],
+ $this->_params['borderwidth'],
+ $this->_params['borderwidth']);
}
// Only shadow the bottom image for 'plain' stacks
if (!$haveBottom) {
$image->destroy();
}
- //@TODO: Was this here for BC with Imagick compiled against older Im?
- // Remove this after I checked against my older IM install
- // If we have a background other than 'none' we need to
- // compose two images together to make sure we *have* a background.
-// if ($this->_params['background'] != 'none') {
-// $size = $this->_image->getDimensions();
-// $new = new Imagick();
-// $new->newImage($length * 1.5 + 20, $length * 1.5 + 20, new ImagickPixel($this->_params['background']));
-// $new->setImageFormat($this->_image->getType());
-// $new->compositeImage($this->_image->imagick, Imagick::COMPOSITE_OVER, 0, 0);
-// $this->_image->imagick->clear();
-// $this->_image->imagick->addImage($new);
-// $new->destroy();
-// }
-
// Trim the canvas before resizing to keep the thumbnails as large
// as possible.
$this->_image->imagick->trimImage(0);
new ImagickPixel($this->_params['background']),
$this->_params['padding'],
$this->_params['padding']);
-
- // @TODO: Same here, did I do this for older Im versions not working
- // right?
- //Horde_Image_Imagick::borderImage($this->_image->imagick,
- // $this->_params['background'],
- // $this->_params['padding'],
- // $this->_params['padding']);
}
return true;
}
// If we have a background other than 'none' we need to
- // compose two images together to make sure we *have* a background.
+ // compose two images together to make sure we *have* a background. We
+ // can't use border because we don't want to extend the image area, just
+ // fill in the parts removed by the rounding.
if ($this->_params['background'] != 'none') {
$size = $this->_image->getDimensions();
$new = new Imagick();
}
/**
- * Utility function to wrap Imagick::borderImage so we can preserve any
- * transparency in the image.
+ * Utility function to wrap Imagick::borderImage. Use when you don't want
+ * to replace all pixels in the clipping area with the border color i.e.
+ * you want to "frame" the existing image. Preserves transparency etc...
*
* @param Imagick &$image The Imagick object to border.
* @param integer $width
*
* @return void
*/
- static public function borderImage(&$image, $color, $width, $height)
+ static public function frameImage(&$image, $color, $width, $height)
{
// Need to jump through these hoops in order to preserve any
// transparency.