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: docs/3.0/api/crop.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,25 +5,25 @@ title: Crop
5
5
6
6
# Crop
7
7
8
-
## Fit `fit=crop`
8
+
## Fit `fit=cover` - Crop to cover the dimensions
9
9
10
10
Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image.
You can also set where the image is cropped by adding a crop position. Accepts `crop-top-left`, `crop-top`, `crop-top-right`, `crop-left`, `crop-center`, `crop-right`, `crop-bottom-left`, `crop-bottom` or `crop-bottom-right`. Default is `crop-center`, and is the same as `crop`.
20
+
You can also set where the image is cropped by adding a crop position. Accepts `cover-top-left`, `cover-top`, `cover-top-right`, `cover-left`, `cover-center`, `cover-right`, `cover-bottom-left`, `cover-bottom` or `cover-bottom-right`. Default is `cover-center`, and is the same as `crop`.
21
21
22
22
~~~html
23
-
<imgsrc="kayaks.jpg?w=300&h=300&fit=crop-left">
23
+
<imgsrc="kayaks.jpg?w=300&h=300&fit=cover-left">
24
24
~~~
25
25
26
-
### Crop Focal Point
26
+
##Fit `fit=crop-x%-y%` - Crop based on Focal Point
27
27
28
28
In addition to the crop position, you can be more specific about the exact crop position using a focal point. This is defined using two offset percentages: `crop-x%-y%`.
29
29
@@ -45,4 +45,4 @@ Crops the image to specific dimensions prior to any other resize operations. Req
Copy file name to clipboardExpand all lines: docs/3.0/api/size.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,14 +29,16 @@ Sets the height of the image, in pixels.
29
29
30
30
Sets how the image is fitted to its target dimensions.
31
31
32
-
### Accepts:
32
+
### Accepts:
33
33
34
34
-`contain`: Default. Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio.
35
-
-`max`: Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio, and will also not increase the size of the image if it is smaller than the output size.
35
+
-`max`: Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio, and will also not increase the size of the image if it is smaller than the output size.
36
36
-`fill`: Resizes the image to fit within the width and height boundaries without cropping or distorting the image, and the remaining space is filled with the background color. The resulting image will match the constraining dimensions.
37
37
-`fill-max`: Resizes the image to fit within the width and height boundaries without cropping but upscaling the image if it's smaller. The finished image will have remaining space on either width or height (except if the aspect ratio of the new image is the same as the old image). The remaining space will be filled with the background color. The resulting image will match the constraining dimensions.
38
38
-`stretch`: Stretches the image to fit the constraining dimensions exactly. The resulting image will fill the dimensions, and will not maintain the aspect ratio of the input image.
39
-
-`crop`: Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. See the [crop](api/crop/) page for more information.
39
+
-`cover`: Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. See the [crop](api/crop/) page for more information.
40
+
-`crop`: Resizes the image to fill the width and height boundaries and crops any excess image data. (alias for `cover`).
41
+
-`crop-x%-y%`: Resizes the image to fill the width and height boundaries and crops based on a focal point defined by `x%` (left offset) and `y%` (top offset). The resulting image will match the width and height constraints without distorting the image. See the [crop](api/crop/) page for more information.
Copy file name to clipboardExpand all lines: docs/3.0/api/watermarks.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,10 +54,11 @@ Sets how the watermark is fitted to its target dimensions.
54
54
-`max`: Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio, and will also not increase the size of the image if it is smaller than the output size.
55
55
-`fill`: Resizes the image to fit within the width and height boundaries without cropping or distorting the image, and the remaining space is filled with the background color. The resulting image will match the constraining dimensions.
56
56
-`stretch`: Stretches the image to fit the constraining dimensions exactly. The resulting image will fill the dimensions, and will not maintain the aspect ratio of the input image.
57
-
-`crop`: Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. See the [crop](api/crop/) page for more information.
57
+
-`cover`: Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. See the [crop](api/crop/) page for more information.
58
+
-`crop-x%-y%`: Resizes the image to fill the width and height boundaries and crops based on a focal point defined by `x%` (left offset) and `y%` (top offset). The resulting image will match the width and height constraints without distorting the image. See the [crop](api/crop/) page for more information.
@@ -89,4 +89,4 @@ It's even possible to use presets with additional parameters:
89
89
90
90
## Overriding defaults and presets
91
91
92
-
You can override the default and preset manipulations for a specific request by passing a new parameter (e.x. `mark=different.png`), or even disable it entirely by setting it to blank (e.x. `mark=`).
92
+
You can override the default and preset manipulations for a specific request by passing a new parameter (e.x. `mark=different.png`), or even disable it entirely by setting it to blank (e.x. `mark=`).
<pclass="message-notice">For simplicity this example has omitted HTTP signatures, however in a production environment it's very important to <ahref="/2.0/config/security/">secure your images</a>.</p>
Copy file name to clipboardExpand all lines: src/Manipulators/Size.php
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -107,11 +107,15 @@ public function getFit(): string
107
107
{
108
108
$fit = (string) $this->getParam('fit');
109
109
110
-
if (in_array($fit, ['contain', 'fill', 'max', 'stretch', 'fill-max'], true)) {
110
+
if (in_array($fit, ['contain', 'fill', 'max', 'stretch', 'fill-max', 'cover'], true)) {
111
111
return$fit;
112
112
}
113
113
114
-
if (preg_match('/^(crop)(-top-left|-top|-top-right|-left|-center|-right|-bottom-left|-bottom|-bottom-right|-[\d]{1,3}-[\d]{1,3}(?:-[\d]{1,3}(?:\.\d+)?)?)*$/', $fit)) {
114
+
if (preg_match('/^(crop|cover)(-top-left|-top|-top-right|-left|-center|-right|-bottom-left|-bottom|-bottom-right?)*$/', $fit)) {
115
+
return'cover';
116
+
}
117
+
118
+
if (preg_match('/^(crop)(-[\d]{1,3}-[\d]{1,3}(?:-[\d]{1,3}(?:\.\d+)?)?)*$/', $fit)) {
115
119
return'crop';
116
120
}
117
121
@@ -245,6 +249,10 @@ public function runResize(ImageInterface $image, string $fit, int $width, int $h
0 commit comments