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_Im_LiquidResize extends Horde_Image_Effect
14: {
15: /**
16: * Valid parameters:
17: * <pre>
18: * width - The target width
19: * height - the target height
20: * ratio - Keep aspect ratio
21: * </pre>
22: *
23: * @var array
24: */
25: protected $_params = array();
26:
27: public function apply()
28: {
29: $this->_params = new Horde_Support_Array($this->_params);
30:
31: $resWidth = $this->_params->width * 2;
32: $resHeight = $this->_params->height * 2;
33:
34: $this->_image->addOperation("-size {$resWidth}x{$resHeight}");
35: if ($this->_params->get('ratio', true)) {
36: $this->_image->addPostSrcOperation('-liquid-rescale' . " {$this->_params->width}x{$this->_params->height}");
37: } else {
38: $this->_image->addPostSrcOperation('-liquid-rescale' . " {$this->_params->width}x{$this->_params->height}!");
39: }
40: $this->_image->clearGeometry();
41: }
42:
43: }