You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-3Lines changed: 32 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,16 +106,45 @@ This will scale the image to as close as it can to the passed dimensions, and th
106
106
107
107
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.
108
108
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
+
112
131
113
132
```php
114
133
$image = new ImageResize('image.jpg');
115
134
$image->crop(200, 200, 1);
116
135
$image->save('image2.jpg');
117
136
```
118
137
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
+
119
148
There is also a way to define custom crop position.
120
149
You can define $x and $y in ```freecrop``` method:
0 commit comments