1: <?php
2: 3: 4: 5: 6: 7:
8: class Ansel_ImageGenerator_PolaroidThumb extends Ansel_ImageGenerator
9: {
10: public $need = array('PolaroidImage');
11:
12: public function __construct($params)
13: {
14: parent::__construct($params);
15: $this->title = _("Polaroids");
16: }
17:
18: 19: 20: 21:
22: protected function _create()
23: {
24: $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
25: min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
26: true);
27:
28: 29:
30: if ($this->_image->gallery > 0) {
31: if (is_null($this->_style)) {
32: $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery);
33: $styleDef = $gal->getStyle();
34: } else {
35: $styleDef = $this->_style;
36: }
37: try {
38: $this->_image->addEffect('PolaroidImage',
39: array('background' => $styleDef->background,
40: 'padding' => 5));
41: if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
42: $this->_image->addEffect('Unsharpmask',
43: array('radius' => $GLOBALS['conf']['thumbnail']['radius'],
44: 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'],
45: 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
46: }
47: $this->_image->applyEffects();
48: } catch (Horde_Image_Exception $e) {
49: throw new Ansel_Exception($e);
50: }
51:
52: return true;
53: }
54: }
55:
56: }
57: