1 <?php
 2 
 3 /**
 4  * Spiegel ein Bild.
 5  *
 6  * @package redaxo\media-manager
 7  */
 8 class rex_effect_flip extends rex_effect_abstract
 9 {
10     private $options;
11 
12     public function __construct()
13     {
14         $this->options = [
15             'X', 'Y', 'XY',
16         ];
17     }
18 
19     public function execute()
20     {
21         $this->media->asImage();
22         $gdimage = $this->media->getImage();
23 
24         // transparenz erhalten (für GIF, PNG & WebP)
25         $this->keepTransparent($gdimage);
26 
27         // --------------- Flip X
28         if ($this->params['flip'] == 'X') {
29             imageflip($gdimage, IMG_FLIP_HORIZONTAL);
30             $this->media->setImage($gdimage);
31         }
32 
33         // --------------- Flip Y
34         if ($this->params['flip'] == 'Y') {
35             imageflip($gdimage, IMG_FLIP_VERTICAL);
36             $this->media->setImage($gdimage);
37         }
38 
39         // --------------- Flip X and Y
40         if ($this->params['flip'] == 'XY') {
41             imageflip($gdimage, IMG_FLIP_BOTH);
42             $this->media->setImage($gdimage);
43         }
44     }
45 
46     public function getName()
47     {
48         return rex_i18n::msg('media_manager_effect_flip');
49     }
50 
51     public function getParams()
52     {
53         return [
54             [
55                 'label' => rex_i18n::msg('media_manager_effect_flip_direction'),
56                 'name' => 'flip',
57                 'type' => 'select',
58                 'options' => $this->options,
59                 'default' => 'X',
60             ],
61         ];
62     }
63 }
64