1 <?php
 2 
 3 class rex_effect_filter_brightness extends rex_effect_abstract
 4 {
 5     public function execute()
 6     {
 7         $this->params['brightness'] = (int) $this->params['brightness'];
 8         if (!$this->params['brightness']) {
 9             $this->params['brightness'] = 0;
10         }
11         if ($this->params['brightness'] < -255) {
12             $this->params['brightness'] = -255;
13         }
14         if ($this->params['brightness'] > 255) {
15             $this->params['brightness'] = 255;
16         }
17         $this->media->asImage();
18         $img = $this->media->getImage();
19 
20         imagefilter($img, IMG_FILTER_BRIGHTNESS, $this->params['brightness']);
21         $this->media->setImage($img);
22     }
23 
24     public function getName()
25     {
26         return rex_i18n::msg('media_manager_effect_brightness');
27     }
28 
29     public function getParams()
30     {
31         return [
32             [
33                 'label' => rex_i18n::msg('media_manager_effect_brightness_value'),
34                 'notice' => rex_i18n::msg('media_manager_effect_brightness_notice'),
35                 'name' => 'brightness',
36                 'type' => 'int',
37                 'default' => '',
38             ],
39         ];
40     }
41 }
42