1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12: class Horde_Image_Effect_Im_CenterCrop extends Horde_Image_Effect
13: {
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: protected $_params = array();
24:
25: public function apply()
26: {
27: $this->_params = new Horde_Support_Array($this->_params);
28: $ver = $this->_image->getIMVersion();
29: if (is_array($ver) && version_compare($ver[0], '6.3.8') < 0) {
30: $initialCrop = $this->_params->width * 2;
31: $command = "-resize x{$initialCrop} -resize '{$initialCrop}x<' -resize 50% -gravity center -crop {$this->_params->width}x{$this->_params->height}+0+0 +repage";
32: } else {
33: $command = "-thumbnail {$this->_params->width}x{$this->_params->height}^ -gravity center -extent {$this->_params->width}x{$this->_params->height}";
34: }
35: $this->_image->addPostSrcOperation($command);
36: $this->_image->clearGeometry();
37:
38: return;
39: }
40:
41: }