-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageResizeInterface.php
243 lines (205 loc) · 5.71 KB
/
ImageResizeInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
namespace AJUR\Toolkit;
interface ImageResizeInterface
{
public const CROPTOP = 1;
public const CROPCENTRE = 2;
public const CROPCENTER = 2;
public const CROPBOTTOM = 3;
public const CROPLEFT = 4;
public const CROPRIGHT = 5;
public const CROPTOPCENTER = 6;
public const IMG_FLIP_HORIZONTAL = 0;
public const IMG_FLIP_VERTICAL = 1;
public const IMG_FLIP_BOTH = 2;
/**
* Loads image source and its properties to the instanciated object
*
* @param string $filename
* @return ImageResize
* @throws ImageResizeException
*/
public function __construct($filename);
/**
* Create instance from a string
*
* @param string $image_data
* @return ImageResize
* @throws ImageResizeException
*/
public static function createFromString(string $image_data): ImageResize;
/**
* Add filter function for use right before save image to file.
*/
public function addFilter(callable $filter): ImageResizeInterface;
/**
* Creating
*
* http://stackoverflow.com/a/28819866
*
* @param $filename
* @return false|resource
* @throws ImageResizeException
*/
public function imageCreateJpegfromExif($filename);
/**
* Saves new image
*
* @param string $filename
* @param integer $image_type
* @param integer $quality
* @param integer $permissions
* @param boolean $exact_size
* @return static
* @throws ImageResizeException
*/
public function save($filename, $image_type = null, $quality = null, $permissions = null, $exact_size = []);
/**
* Convert the image to string
*
* @param int $image_type
* @param int $quality
* @return string
* @throws ImageResizeException
*/
public function getImageAsString($image_type = null, $quality = null);
/**
* Convert the image to string with the current settings
*
* @return string
* @throws ImageResizeException
*/
public function __toString();
/**
* Outputs image to browser
*
* @param string $image_type
* @param integer $quality
* @throws ImageResizeException
*/
public function output($image_type = null, $quality = null);
/**
* [FLUENT] Resizes image according to the given short side (short side proportional)
*
* @param integer $max_short
* @param boolean $allow_enlarge
* @return static
*/
public function resizeToShortSide($max_short, $allow_enlarge = false);
/**
* [FLUENT] Resizes image according to the given long side (short side proportional)
*
* @param integer $max_long
* @param boolean $allow_enlarge
* @return static
*/
public function resizeToLongSide($max_long, $allow_enlarge = false);
/**
* [FLUENT] Resizes image according to the given height (width proportional)
*
* @param integer $height
* @param boolean $allow_enlarge
* @return static
*/
public function resizeToHeight($height, $allow_enlarge = false);
/**
* [FLUENT] Resizes image according to the given width (height proportional)
*
* @param integer $width
* @param boolean $allow_enlarge
* @return static
*/
public function resizeToWidth($width, $allow_enlarge = false);
/**
* [FLUENT] Resizes image to best fit inside the given dimensions
*
* @param integer $max_width
* @param integer $max_height
* @param boolean $allow_enlarge
* @return static
*/
public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false);
/**
* [FLUENT] Resizes image according to given scale (proportionally)
*
* @param integer|float $scale
* @return static
*/
public function scale($scale);
/**
* [FLUENT] Resizes image according to the given width and height
*
* @param integer $width
* @param integer $height
* @param boolean $allow_enlarge
* @return static
*/
public function resize($width, $height, $allow_enlarge = false);
/**
* [FLUENT] Crops image according to the given width, height and crop position
*
* @param integer $width
* @param integer $height
* @param boolean $allow_enlarge
* @param integer $position
* @return static
*/
public function crop($width, $height, $allow_enlarge = false, $position = self::CROPCENTER);
/**
* [FLUENT] Crops image according to the given width, height, x and y
*
* @param integer $width
* @param integer $height
* @param mixed $x
* @param mixed $y
* @return static
*/
public function freecrop($width, $height, $x = false, $y = false);
/**
* Gets source width
*
* @return integer
*/
public function getSourceWidth();
/**
* Gets source height
*
* @return integer
*/
public function getSourceHeight();
/**
* Gets width of the destination image
*
* @return integer
*/
public function getDestWidth();
/**
* Gets height of the destination image
* @return integer
*/
public function getDestHeight();
/**
* Enable or not the gamma color correction on the image, enabled by default
*
* @param bool $enable
* @return static
*/
public function gamma($enable = false);
/**
* Set JPEG Quality
*
* @param $quality
* @return static
*/
public function setQualityJPEG($quality);
/**
* @param $quality
* @return static
*/
public function setQualityPNG($quality);
/**
* @param $quality
* @return static
*/
public function setQualityWebp($quality);
}