Skip to content

Commit

Permalink
Docs: add image with examples of resize fit property
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Dec 21, 2022
1 parent da0b594 commit efbb0c2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/api-resize.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ When both a `width` and `height` are provided, the possible methods by which the

Some of these values are based on the [object-fit][1] CSS property.

<img alt="Examples of various values for the fit property when resizing" width="100%" style="aspect-ratio: 998/243" src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/image/api-resize-fit.png">

When using a **fit** of `cover` or `contain`, the default **position** is `centre`. Other options are:

* `sharp.position`: `top`, `right top`, `right`, `right bottom`, `bottom`, `left bottom`, `left`, `left top`.
Expand Down
Binary file added docs/image/api-resize-fit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ function isResizeExpected (options) {
*
* Some of these values are based on the [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) CSS property.
*
* <img alt="Examples of various values for the fit property when resizing" width="100%" style="aspect-ratio: 998/243" src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/image/api-resize-fit.png">
*
* When using a **fit** of `cover` or `contain`, the default **position** is `centre`. Other options are:
* - `sharp.position`: `top`, `right top`, `right`, `right bottom`, `bottom`, `left bottom`, `left`, `left top`.
* - `sharp.gravity`: `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` or `centre`.
Expand Down

0 comments on commit efbb0c2

Please sign in to comment.