1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13: class Ansel_ImageGenerator_SquareThumb extends Ansel_ImageGenerator
14: {
15: public function __construct($params)
16: {
17: parent::__construct($params);
18: $this->title = _("Square Thumbnails");
19: if (empty($this->_params['width'])) {
20: $this->_params['width'] = $this->_style->width;
21: }
22: if (empty($this->_params['height'])) {
23: $this->_params['height'] = $this->_style->height;
24: }
25: }
26:
27: 28: 29: 30:
31: protected function _create()
32: {
33:
34: if (empty($this->_params['width'])) {
35: $size = min($GLOBALS['conf']['thumbnail']['height'], $GLOBALS['conf']['thumbnail']['width']);
36: } else {
37: $size = min($this->_params['width'], $this->_params['height']);
38: }
39:
40:
41: if (Ansel::isAvailable('SmartCrop') && $GLOBALS['conf']['image']['smartcrop']) {
42: $this->_image->addEffect('SmartCrop', array('width' => $size, 'height' => $size));
43: } else {
44: $this->_image->addEffect('CenterCrop', array('width' => $size, 'height' => $size));
45: }
46: $this->_image->applyEffects();
47:
48: if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
49: try {
50: $this->_image->addEffect('Unsharpmask',
51: array('radius' => $GLOBALS['conf']['thumbnail']['radius'],
52: 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'],
53: 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
54: $this->_image->applyEffects();
55: } catch (Horde_Image_Exception $e) {
56: throw new Ansel_Exception($e);
57: }
58: }
59:
60: return $this->_image->getHordeImage();
61: }
62:
63: }
64: