1: <?php
2: /**
3: * Image effect for applying content aware image resizing.
4: *
5: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (LGPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
9: *
10: * @author Michael J. Rubinsky <mrubinsk@horde.org>
11: * @package Image
12: */
13: class Horde_Image_Effect_Imagick_LiquidResize extends Horde_Image_Effect
14: {
15: /**
16: *
17: * Valid parameters:
18: * <pre>
19: * width - The target width
20: * height - the target height
21: * delta_x - How much the seam may move on x axis (A value of 0
22: * causes the seam to be straight).
23: * rigidity - Introduces a bias for non-straight seams. Typically zero
24: * </pre>
25: *
26: * @var array
27: */
28: protected $_params = array();
29:
30: public function apply()
31: {
32: $this->_params = new Horde_Support_Array($this->_params);
33: try {
34: // Only supported if ImageMagick is compiled against lqr library.
35: if (method_exists($this->_image->imagick, 'liquidRescaleImage')) {
36: $this->_image->imagick->liquidRescaleImage(
37: $this->_params->width, $this->_params->height, $this->_params->delta_x, $this->_params->rigidity);
38: } else {
39: throw new Horde_Image_Exception('Missing support for lqr in ImageMagick.');
40: }
41: } catch (ImagickException $e) {
42: throw new Horde_Image_Exception($e);
43: }
44: }
45:
46: }