Skip to content

Commit b066027

Browse files
dochnethomasgauvin
authored andcommitted
document the images features fit: squeeze and trim: border (#23862)
1 parent 72bbc47 commit b066027

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/content/partials/images/fit.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Affects interpretation of `width` and `height`. All resizing modes preserve aspe
1616
Image will be shrunk and cropped to fit within the area specified by `width` and `height`. The image will not be enlarged. For images smaller than the given dimensions, it is the same as `scale-down`. For images larger than the given dimensions, it is the same as `cover`. See also [`trim`](#trim)
1717
- `pad`\
1818
Resizes to the maximum size that fits within the given `width` and `height`, and then fills the remaining area with a `background` color (white by default). This mode is not recommended, since you can achieve the same effect more efficiently with the `contain` mode and the CSS `object-fit: contain` property.
19-
19+
- `squeeze`
20+
Resizes the image to the exact width and height specified. This mode does not preserve the original aspect ratio and will cause the image to appear stretched or squashed.
2021
<Tabs>
2122
<TabItem label="URL format">
2223
```js

src/content/partials/images/trim.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,38 @@ Specifies a number of pixels to cut off on each side. Allows removal of borders
2020
cf: {image: {trim: {top: 12, right: 78, bottom: 34, left: 56, width:678, height:678}}}
2121
```
2222
</TabItem>
23+
</Tabs>
24+
25+
The API also supports automatic border removal based on color. This can be enabled by setting `trim=border` for automatic color detection, or customized with the parameters below.
26+
27+
`trim.border.color`
28+
The border color to trim. Accepts any CSS color using CSS4 modern syntax, such as `rgb(255 255 0)`. If omitted, the color is detected automatically.
29+
30+
`trim.border.tolerance`
31+
The matching tolerance for the color, on a scale of 0 to 255.
32+
33+
`trim.border.keep`
34+
The number of pixels of the original border to leave untrimmed.
35+
36+
<Tabs>
37+
<TabItem label="URL format">
38+
```js
39+
trim=border
40+
41+
OR
42+
43+
trim.border.color=%23000000
44+
trim.border.tolerance=5
45+
trim.border.keep=10
46+
```
47+
</TabItem>
48+
<TabItem label="Workers">
49+
```js
50+
cf: {image: {trim: "border"}}
51+
52+
OR
53+
54+
cf: {image: {trim: {border: {color: "#000000", tolerance: 5, keep: 10}}}}
55+
```
56+
</TabItem>
2357
</Tabs>

0 commit comments

Comments
 (0)