1 | <?php |
||
20 | class ImageStyler |
||
21 | { |
||
22 | /** |
||
23 | * @var |
||
24 | */ |
||
25 | private $compression = 90; |
||
26 | /** |
||
27 | * @var |
||
28 | */ |
||
29 | private $cropCoordinates = []; |
||
30 | /** |
||
31 | * @var |
||
32 | */ |
||
33 | private $driver = 'gd'; |
||
34 | /** |
||
35 | * @var |
||
36 | */ |
||
37 | private $focusCoordinates = []; |
||
38 | /** |
||
39 | * @var |
||
40 | */ |
||
41 | private $image; |
||
42 | /** |
||
43 | * @var |
||
44 | */ |
||
45 | private $manager; |
||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | private $styleData = []; |
||
50 | |||
51 | /** |
||
52 | * ImageStyler constructor. |
||
53 | * |
||
54 | * @param array $responsiveImageConfig |
||
55 | */ |
||
56 | public function __construct($responsiveImageConfig = []) |
||
65 | |||
66 | /** |
||
67 | * Separates the crop and focus coordinates from the image object and stores them. |
||
68 | * |
||
69 | * @param $cropFocusCoords |
||
70 | */ |
||
71 | public function setCoordinateGroups($cropFocusCoords) |
||
78 | |||
79 | /** |
||
80 | * Returns the style information of a defined style. |
||
81 | * |
||
82 | * @param array $style |
||
83 | */ |
||
84 | public function setStyleData($style = []) |
||
91 | |||
92 | /** |
||
93 | * @param $width |
||
94 | * @param $height |
||
95 | */ |
||
96 | protected function scaleImage($width, $height) |
||
106 | |||
107 | /** |
||
108 | * @param $source |
||
109 | * @param string $driver |
||
110 | */ |
||
111 | protected function setImage($source, $driver = 'gd') |
||
118 | |||
119 | /** |
||
120 | * Performs the image manipulation using current style information |
||
121 | * and user defined crop and focus rectangles. |
||
122 | * |
||
123 | * @param $source |
||
124 | * @param $destination |
||
125 | * @param array $style |
||
126 | * @param null $cropFocusCoords |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public function createImage($source, $destination, array $style = [], $cropFocusCoords = null) |
||
196 | |||
197 | /** |
||
198 | * @param $width |
||
199 | * @param $height |
||
200 | * @param $xOffset |
||
201 | * @param $yOffset |
||
202 | */ |
||
203 | protected function cropImage($width, $height, $xOffset, $yOffset) |
||
212 | |||
213 | /** |
||
214 | * Crops out defined crop area. |
||
215 | */ |
||
216 | protected function doCropRectangle() |
||
231 | |||
232 | /** |
||
233 | * @param string $type |
||
234 | * |
||
235 | * @return bool |
||
236 | */ |
||
237 | protected function getCoordinates($type = 'crop') |
||
254 | |||
255 | /** |
||
256 | * @param $destination |
||
257 | * |
||
258 | * @return mixed |
||
259 | */ |
||
260 | protected function saveImage($destination) |
||
266 | } |