An open API service indexing awesome lists of open source software.

https://github.com/awes-io/resize

Cloudflare Image Resizing: simple API for URL generation.
https://github.com/awes-io/resize

api cloudflare crop cropping image resize resizing

Last synced: 3 months ago
JSON representation

Cloudflare Image Resizing: simple API for URL generation.

Awesome Lists containing this project

README

        



Awes.io logo

Cloudflare Image Resizing

>

Simple API for URL generation.



Last version


License


Analytics

### Setup
```bash
yarn add @awes-io/resize # yarn
npm i @awes-io/resize # npm
```

### Basic use

```javascript
import resize from '@awes-io/resize'

// get the image with width 640px
resize('https://example.com/images/example.jpg', 640)

// result: https://example.com/cdn-cgi/image/w=640,q=75/images/example.jpg
```

### Method

```javascript
// URL generation with parameters for resizing
resize(url, width = null, aspect = null, options = null)
```

### Options

| Name | Type | Default | Description |
| ---------------- | -------- | ------- | ----------------------------------------------------- |
| url | `String` | - | Link to the original image. |
| width | `Number` | null | (Optional) Width of the image, undefined by default. |
| aspect | `String` | null | (Optional) Aspect ratio for image, ie: 16x9, 4:3, etc.|
| options | `Object` | null | (Optional) domain, protocol, crop, prefix |
| options.options | `Object` | null | (Optional) List of options for modify parameters for image. More info: https://developers.cloudflare.com/images/about/ |

### Cloudflare Image Resizing Documentation
- [https://developers.cloudflare.com/images/about/](https://developers.cloudflare.com/images/about/)

Ensure to write proper commit message according to [Git Commit convention](https://www.conventionalcommits.org/)