@@ -123,7 +123,7 @@ public function resize($width, $height = 0, $method = 's') {
123
123
}
124
124
125
125
public function stretch ($ width , $ height = 0 ) {
126
- if (! $ this ->width || ! $ this ->height ) {
126
+ if (! $ this ->width || ! $ this ->height || ! $ this -> image ) {
127
127
return ;
128
128
}
129
129
@@ -152,6 +152,10 @@ public function stretch($width, $height = 0) {
152
152
}
153
153
154
154
public function crop ($ topX , $ topY , $ bottomX , $ bottomY ) {
155
+ if (! $ this ->width || ! $ this ->height || ! $ this ->image ) {
156
+ return ;
157
+ }
158
+
155
159
$ imageOld = $ this ->image ;
156
160
$ this ->image = imagecreatetruecolor ($ bottomX - $ topX , $ bottomY - $ topY );
157
161
@@ -163,7 +167,7 @@ public function crop($topX, $topY, $bottomX, $bottomY) {
163
167
}
164
168
165
169
public function cropsize ($ width , $ height = 0 ) {
166
- if (! $ this ->width || ! $ this ->height ) {
170
+ if (! $ this ->width || ! $ this ->height || ! $ this -> image ) {
167
171
return ;
168
172
}
169
173
@@ -185,7 +189,14 @@ public function cropsize($width, $height = 0) {
185
189
$ crop_y = 0 ;
186
190
}
187
191
188
- $ this ->image = imagescale ($ this ->image , $ newWidth , $ newHeight , IMG_BICUBIC_FIXED );
189
- $ this ->image = imagecrop ($ this ->image , ['x ' => 0 , 'y ' => 0 , 'width ' => $ width , 'height ' => $ height ]);
192
+ $ image = imagescale ($ this ->image , $ newWidth , $ newHeight , IMG_BICUBIC_FIXED );
193
+
194
+ if ($ image ) {
195
+ $ image = imagecrop ($ image , ['x ' => 0 , 'y ' => 0 , 'width ' => $ width , 'height ' => $ height ]);
196
+
197
+ if ($ image ) {
198
+ $ this ->image = $ image ;
199
+ }
200
+ }
190
201
}
191
202
}
0 commit comments