Skip to content

Commit

Permalink
Fix DropShadow generation when providing a background image in Im/Ima…
Browse files Browse the repository at this point in the history
…gick
  • Loading branch information
mrubinsk committed Jan 20, 2017
1 parent 0da3bd7 commit 80fe0f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion framework/Image/lib/Horde/Image/Effect/Im/DropShadow.php
Expand Up @@ -50,7 +50,7 @@ public function apply()
'\( +clone -background black -shadow 80x' . $this->_params['fade']
. '+' . $this->_params['distance']
. '+' . $this->_params['distance']
. ' \) +swap -background none -flatten +repage -bordercolor '
. ' \) +swap -background ' . $this->_params['background'] . ' -flatten +repage -bordercolor '
. $this->_params['background']
. ' -border ' . $this->_params['padding']
);
Expand Down
14 changes: 14 additions & 0 deletions framework/Image/lib/Horde/Image/Effect/Imagick/DropShadow.php
Expand Up @@ -60,6 +60,20 @@ public function apply()
$this->_params['distance']
);

// If we explicitly request a background color, we need to compose
// an image of the background color with the shadow since the
// shadow is always generated with transparent background.
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
);
Expand Down

0 comments on commit 80fe0f7

Please sign in to comment.