@@ -36,7 +36,7 @@ class ImageStyler
36
36
*/
37
37
private $ focusCoordinates = [];
38
38
/**
39
- * @var
39
+ * @var \Intervention\Image\Image
40
40
*/
41
41
private $ image ;
42
42
/**
@@ -71,8 +71,8 @@ public function __construct($responsiveImageConfig = [])
71
71
public function setCoordinateGroups ($ cropFocusCoords )
72
72
{
73
73
// x1, y1, x2, y2:x3, y3, x4, y4
74
- $ coordsSets = explode (': ' , $ cropFocusCoords );
75
- $ this ->cropCoordinates = explode (', ' , $ coordsSets [0 ]);
74
+ $ coordsSets = explode (': ' , $ cropFocusCoords );
75
+ $ this ->cropCoordinates = explode (', ' , $ coordsSets [0 ]);
76
76
$ this ->focusCoordinates = explode (', ' , $ coordsSets [1 ]);
77
77
}
78
78
@@ -83,9 +83,9 @@ public function setCoordinateGroups($cropFocusCoords)
83
83
*/
84
84
public function setStyleData ($ style = [])
85
85
{
86
- $ this ->styleData ['effect ' ] = empty ($ style ['effect ' ]) ? null : $ style ['effect ' ];
87
- $ this ->styleData ['width ' ] = empty ($ style ['width ' ]) ? null : $ style ['width ' ];
88
- $ this ->styleData ['height ' ] = empty ($ style ['height ' ]) ? null : $ style ['height ' ];
86
+ $ this ->styleData ['effect ' ] = empty ($ style ['effect ' ]) ? null : $ style ['effect ' ];
87
+ $ this ->styleData ['width ' ] = empty ($ style ['width ' ]) ? null : $ style ['width ' ];
88
+ $ this ->styleData ['height ' ] = empty ($ style ['height ' ]) ? null : $ style ['height ' ];
89
89
$ this ->styleData ['greyscale ' ] = empty ($ style ['greyscale ' ]) ? null : $ style ['greyscale ' ];
90
90
}
91
91
@@ -123,7 +123,7 @@ protected function setImage($source, $driver = 'gd')
123
123
* @param $source
124
124
* @param $destination
125
125
* @param array $style
126
- * @param null $cropFocusCoords
126
+ * @param null $cropFocusCoords
127
127
*
128
128
* @return string
129
129
*/
@@ -202,12 +202,16 @@ function ($constraint) {
202
202
*/
203
203
protected function cropImage ($ width , $ height , $ xOffset , $ yOffset )
204
204
{
205
- $ this ->image ->crop (
206
- round ($ width ),
207
- round ($ height ),
208
- round ($ xOffset ),
209
- round ($ yOffset )
210
- );
205
+ try {
206
+ $ this ->image ->crop (
207
+ round ($ width ),
208
+ round ($ height ),
209
+ round ($ xOffset ),
210
+ round ($ yOffset )
211
+ );
212
+ } catch (Exception $ exception ) {
213
+ throw new ImageProcessingException ($ e ->getMessage );
214
+ }
211
215
}
212
216
213
217
/**
@@ -221,11 +225,11 @@ protected function doCropRectangle()
221
225
$ geometry = new CoordinateGeometry ($ cropCoords [0 ], $ cropCoords [1 ], $ cropCoords [2 ], $ cropCoords [3 ]);
222
226
223
227
// Get the lengths.
224
- $ newWidth = $ geometry ->axisLength ('x ' );
228
+ $ newWidth = $ geometry ->axisLength ('x ' );
225
229
$ newHeight = $ geometry ->axisLength ('y ' );
226
230
227
231
// Do the initial crop.
228
- $ this ->image -> crop ($ newWidth , $ newHeight , $ cropCoords [0 ], $ cropCoords [1 ]);
232
+ $ this ->cropImage ($ newWidth , $ newHeight , $ cropCoords [0 ], $ cropCoords [1 ]);
229
233
}
230
234
}
231
235
@@ -237,7 +241,7 @@ protected function doCropRectangle()
237
241
protected function getCoordinates ($ type = 'crop ' )
238
242
{
239
243
$ coords = $ this ->{$ type . 'Coordinates ' };
240
- $ valid = 0 ;
244
+ $ valid = 0 ;
241
245
foreach ($ coords as $ id => $ coord ) {
242
246
if ($ coord > 0 ) {
243
247
$ valid ++;
0 commit comments