Skip to content

Commit 4af1449

Browse files
authored
Create README.md
1 parent 9c59267 commit 4af1449

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,45 @@ This will scale the image to as close as it can to the passed dimensions, and th
106106

107107
In the case of the example above, an image of 400px × 600px will be resized down to 200px × 300px, and then 50px will be taken off the top and bottom, leaving you with 200px × 200px.
108108

109-
By default the crop function will crop the center of you image, but there are other options available.
110-
Depending on your needs you can also decide to crop the top, the bottom, the left, the right, or between the top and the center of your image.
111-
If for instance you want to crop the top of your image here is an example of how you can do it :
109+
Crop modes:
110+
111+
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.
112+
The default crop mode used is the 'CROPCENTER' one which value is 2.
113+
As a result those pieces of code are equivalent:
114+
115+
```php
116+
$image = new ImageResize('image.jpg');
117+
$image->crop(200, 200);
118+
$image->save('image2.jpg');
119+
```
120+
121+
```php
122+
$image = new ImageResize('image.jpg');
123+
$image->crop(200, 200, 2);
124+
$image->save('image2.jpg');
125+
```
126+
127+
In the case you have an image of 400px × 600px and you want to crop it to 200px × 200px the image will be resized down to 200px × 300px, then you can indicate how you want to handle those 100px exceeding passing the value of the crop mode you want to use.
128+
129+
For instance passing the crop mode 'CROPTOP' equal to 1 will result as 100px taken off the bottom leaving you with 200px × 200px.
130+
112131

113132
```php
114133
$image = new ImageResize('image.jpg');
115134
$image->crop(200, 200, 1);
116135
$image->save('image2.jpg');
117136
```
118137

138+
On the contrary passing the crop mode 'CROPBOTTOM' equal to 3 will result as 100px taken off the top leaving you with 200px × 200px.
139+
140+
```php
141+
$image = new ImageResize('image.jpg');
142+
$image->crop(200, 200, 3);
143+
$image->save('image2.jpg');
144+
```
145+
146+
Freecrop:
147+
119148
There is also a way to define custom crop position.
120149
You can define $x and $y in ```freecrop``` method:
121150

0 commit comments

Comments
 (0)