Skip to content

Commit d38555e

Browse files
committed
check imageflip is existed and add imageFlip usage
1 parent 785aeea commit d38555e

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ In the case of the example above, an image of 400px × 600px will be resize
129129

130130
Crop modes:
131131

132-
Few crop mode options are available in order for you to choose how you want to handle the eventual exceeding width or height after resizing down your image.
132+
Few crop mode options are available in order for you to choose how you want to handle the eventual exceeding width or height after resizing down your image.
133133
The default crop mode used is the `CROPCENTER`.
134-
As a result those pieces of code are equivalent:
134+
As a result those pieces of code are equivalent:
135135

136136
```php
137137
$image = new ImageResize('image.jpg');
@@ -269,7 +269,7 @@ By default, [image interlacing](http://php.net/manual/en/function.imageinterlace
269269
$image = new ImageResize('image.jpg');
270270
$image->scale(50);
271271
$image->interlace = 0;
272-
$image->save('image2.jpg')
272+
$image->save('image2.jpg');
273273
```
274274

275275
Chaining
@@ -305,26 +305,26 @@ try{
305305
$image = new ImageResize(null);
306306
echo "This line will not be printed";
307307
} catch (ImageResizeException $e) {
308-
echo "Something went wrong" . $e->getMessage();
308+
echo "Something went wrong" . $e->getMessage();
309309
}
310310
```
311-
311+
312312
Filters
313313
--------
314-
315-
You can apply special effects for new image like blur or add banner.
314+
315+
You can apply special effects for new image like blur or add banner.
316316

317317
```php
318318
$image = new ImageResize('image.jpg');
319319

320320
// Add blure
321-
$image->addFIlter(function ($imageDesc) {
321+
$image->addFilter(function ($imageDesc) {
322322
imagefilter($imageDesc, IMG_FILTER_GAUSSIAN_BLUR);
323323
});
324324

325325
// Add banner on bottom left corner
326326
$image18Plus = 'banner.png'
327-
$image->addFIlter(function ($imageDesc) use ($image18Plus) {
327+
$image->addFilter(function ($imageDesc) use ($image18Plus) {
328328
$logo = imagecreatefrompng($image18Plus);
329329
$logo_width = imagesx($logo);
330330
$logo_height = imagesy($logo);
@@ -336,10 +336,23 @@ $image->addFIlter(function ($imageDesc) use ($image18Plus) {
336336
});
337337

338338
```
339-
339+
340+
Flip
341+
--------
342+
343+
Flips an image using a given mode and this method is only for PHP version 5.4.
344+
345+
```php
346+
$flip = new ImageResize('image.png');
347+
$image = imagecreatetruecolor(200, 100);
348+
349+
$flip->imageFlip($image, 0);
350+
351+
```
352+
340353
Both functions will be used in the order in which they were added.
341-
342-
354+
355+
343356
API Doc
344357
-------
345358

lib/ImageResize.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ public function imageCreateJpegfromExif($filename)
188188
}
189189

190190
if ($orientation === 5 || $orientation === 4 || $orientation === 7) {
191-
imageflip($img, IMG_FLIP_HORIZONTAL);
191+
if(function_exists('imageflip')) {
192+
imageflip($img, IMG_FLIP_HORIZONTAL);
193+
} else {
194+
$this->imageFlip($img, IMG_FLIP_HORIZONTAL);
195+
}
192196
}
193197

194198
return $img;

0 commit comments

Comments
 (0)