66 lines
1.7 KiB
Plaintext
66 lines
1.7 KiB
Plaintext
|
|
meta {
|
||
|
|
name: Image resize
|
||
|
|
type: http
|
||
|
|
seq: 2
|
||
|
|
}
|
||
|
|
|
||
|
|
get {
|
||
|
|
url: https://imgresize.memori.ai/api/imgresize/:width/:height/:url?format={{format}}&fit={{fit}}
|
||
|
|
body: none
|
||
|
|
auth: inherit
|
||
|
|
}
|
||
|
|
|
||
|
|
params:query {
|
||
|
|
format: {{format}}
|
||
|
|
fit: {{fit}}
|
||
|
|
}
|
||
|
|
|
||
|
|
params:path {
|
||
|
|
width: 200
|
||
|
|
height: 200
|
||
|
|
url: https%3A%2F%2Fmemori.ai%2Flogo.png
|
||
|
|
}
|
||
|
|
|
||
|
|
vars:pre-request {
|
||
|
|
format: png
|
||
|
|
fit: inside
|
||
|
|
}
|
||
|
|
|
||
|
|
docs {
|
||
|
|
# Image resize API
|
||
|
|
|
||
|
|
Endpoint: [https://imgresize.memori.ai](https://imgresize.memori.ai).
|
||
|
|
|
||
|
|
Repo: [https://code.nzambello.dev/nzambello/resize-img-api](https://code.nzambello.dev/nzambello/resize-img-api).
|
||
|
|
|
||
|
|
# resize-img-api
|
||
|
|
|
||
|
|
The structure of the API path is:
|
||
|
|
|
||
|
|
```
|
||
|
|
/api/imgresize/:width/:height/:url
|
||
|
|
```
|
||
|
|
|
||
|
|
Where `:width` and `:height` can be numbers in pixels or `auto`.
|
||
|
|
|
||
|
|
The `:url` is the URL of the image to be resized and should be URL encoded, which can be done in JS with `encodeURIComponent`(). See [MDN ref](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent).
|
||
|
|
|
||
|
|
Example encoded URL for [https://memori.ai/logo.png](https://memori.ai/logo.png):
|
||
|
|
|
||
|
|
```
|
||
|
|
https%3A%2F%2Fmemori.ai%2Flogo.png
|
||
|
|
```
|
||
|
|
|
||
|
|
Then call the API as, for example:
|
||
|
|
|
||
|
|
```
|
||
|
|
/api/imgresize/200/200/https%3A%2F%2Fmemori.ai%2Flogo.png
|
||
|
|
```
|
||
|
|
|
||
|
|
You can also specify a format using the querystring `?format=` and indicating one of the following: `avif`, `gif`, `heif`, `jpeg`, `jpg`, `pdf`, `png`, `svg`, `tiff`, `webp`. (Note: Experimental!)
|
||
|
|
|
||
|
|
Another querystring parameter is `fit` which can be `cover`, `contain`, `fill`, `inside`, `outside` (Ref: [sharp](https://sharp.pixelplumbing.com/api-resize#resize)). Default is `inside`.
|
||
|
|
|
||
|
|
|
||
|
|
}
|