1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10: class Horde_Image_Effect_Imagick_PolaroidImage extends Horde_Image_Effect
11: {
12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24:
25: 26: 27:
28: protected $_params = array('background' => 'none',
29: 'angle' => 0,
30: 'shadowcolor' => 'black');
31:
32: 33: 34: 35:
36: public function apply()
37: {
38: if (!method_exists($this->_image->imagick, 'polaroidImage') ||
39: !method_exists($this->_image->imagick, 'trimImage')) {
40: throw new Horde_Image_Exception('Your version of Imagick is not compiled against a recent enough ImageMagick library to use the PolaroidImage effect.');
41: }
42:
43:
44: $this->_image->imagick->setImageBackgroundColor(new ImagickPixel($this->_params['shadowcolor']));
45: $this->_image->imagick->polaroidImage(new ImagickDraw(), $this->_params['angle']);
46:
47:
48:
49:
50: $size = $this->_image->getDimensions();
51: $imk = new Imagick();
52: $imk->newImage($size['width'], $size['height'], $this->_params['background']);
53: $imk->setImageFormat($this->_image->getType());
54: $result = $imk->compositeImage($this->_image->imagick, Imagick::COMPOSITE_OVER, 0, 0);
55: $this->_image->imagick->clear();
56: $this->_image->imagick->addImage($imk);
57: $imk->destroy();
58:
59: return true;
60: }
61:
62: }