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
+39
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,45 @@ This will scale the image to as close as it can to the passed dimensions, and th
118
118
119
119
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.
120
120
121
+
Crop modes:
122
+
123
+
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.
124
+
The default crop mode used is the `CROPCENTER`.
125
+
As a result those pieces of code are equivalent:
126
+
127
+
```php
128
+
$image = new ImageResize('image.jpg');
129
+
$image->crop(200, 200);
130
+
$image->save('image2.jpg');
131
+
```
132
+
133
+
```php
134
+
$image = new ImageResize('image.jpg');
135
+
$image->crop(200, 200, ImageResize::CROPCENTER);
136
+
$image->save('image2.jpg');
137
+
```
138
+
139
+
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.
140
+
141
+
For instance passing the crop mode `CROPTOP` will result as 100px taken off the bottom leaving you with 200px × 200px.
142
+
143
+
144
+
```php
145
+
$image = new ImageResize('image.jpg');
146
+
$image->crop(200, 200, ImageResize::CROPTOP);
147
+
$image->save('image2.jpg');
148
+
```
149
+
150
+
On the contrary passing the crop mode `CROPBOTTOM` will result as 100px taken off the top leaving you with 200px × 200px.
151
+
152
+
```php
153
+
$image = new ImageResize('image.jpg');
154
+
$image->crop(200, 200, ImageResize::CROPBOTTOM);
155
+
$image->save('image2.jpg');
156
+
```
157
+
158
+
Freecrop:
159
+
121
160
There is also a way to define custom crop position.
122
161
You can define $x and $y in ```freecrop``` method:
0 commit comments