1: <?php
2: /**
3: * Image border Effect for the Horde_Image package.
4: *
5: * @author Chuck Hagenbuch <chuck@horde.org>
6: * @package Image
7: */
8: class Horde_Image_Effect_Imagick_Border extends Horde_Image_Effect
9: {
10: /**
11: * Valid parameters for border effects:
12: *
13: * bordercolor - Border color. Defaults to black.
14: * borderwidth - Border thickness, defaults to 1 pixel.
15: * preserve - Preserves the alpha transparency layer (if present)
16: *
17: * @var array
18: */
19: protected $_params = array('bordercolor' => 'black',
20: 'borderwidth' => 1,
21: 'preserve' => true);
22:
23: /**
24: * Draw the border.
25: *
26: * This draws the configured border to the provided image. Beware,
27: * that every pixel inside the border clipping will be overwritten
28: * with the background color.
29: */
30: public function apply()
31: {
32: if ($this->_params['preserve']) {
33: Horde_Image_Imagick::frameImage($this->_image->imagick,
34: $this->_params['bordercolor'],
35: $this->_params['borderwidth'],
36: $this->_params['borderwidth']);
37: } else {
38: $this->_image->imagick->borderImage(
39: new ImagickPixel($this->_params['bordercolor']),
40: $this->_params['borderwidth'],
41: $this->_params['borderwidth']);
42: }
43:
44: return true;
45: }
46:
47: }