function image_imagick_shadow in Imagick 7
Genrates a shadow around an image
Parameters
$image: An image object. The $image->resource value will be modified by this call.
$color: The color of the shadow.
$opacity: The opacity of the shadow.
$sigma: The sigma of the shadow.
$x: The angle of the shadow.
$y: The angle of the shadow.
Return value
TRUE or FALSE, based on success.
File
- effects/
imagick.shadow.inc, line 21
Code
function image_imagick_shadow(stdClass $image, $color, $opacity, $sigma, $x, $y) {
$color = empty($color) ? 'none' : $color;
$shadow = clone $image->resource;
$shadow
->setImageBackgroundColor(new ImagickPixel($color));
$shadow
->shadowImage($opacity, $sigma, $x, $y);
$shadow
->compositeImage($image->resource, Imagick::COMPOSITE_OVER, $x + $sigma * 2, $y + $sigma * 2);
// Reset image dimensions
$dimensions = $shadow
->getImageGeometry();
$shadow
->setImagePage($dimensions['width'], $dimensions['height'], 0, 0);
$image->info['width'] = $dimensions['width'];
$image->info['height'] = $dimensions['height'];
$image->resource = $shadow;
return $image->resource;
}