> For the complete documentation index, see [llms.txt](https://docs.cloudimage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudimage.io/setup/shortening-urls/rules.md).

# Rules

Cloudimage lets you define transformation rules based on image path and filename pattern matching.

All [Image operations](/transformations/image-operations.md) and [Image filters](/transformations/image-filters.md) can be included in a rule, as well as [Image watermarking](/transformations/image-watermarking.md) and [Image compression](/transformations/image-compression.md) parameters.

## Defining rules <a href="#od_f075733a" id="od_f075733a"></a>

You can define your presets in the admin panel, *Image Settings / Rules*.

<figure><img src="/files/Vsa9ukpPsa4252yzfnv3" alt=""><figcaption></figcaption></figure>

## Using Rules <a href="#od_cf858787" id="od_cf858787"></a>

### **Examples**

| Rule pattern | Operations and filters                                                                                                                                                                       |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -avatar.jpg  | <mark style="color:orange;">**func=crop**</mark>&<mark style="color:orange;">**w=300**</mark>&<mark style="color:orange;">**h=300**</mark>&<mark style="color:orange;">**radius=max**</mark> |

Here is an image using the rules from above:

| Preview                          | Syntax                                                                                                                     |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| ![](/files/lhXDvy0Pii5olaL3mPXY) | [//samples.scaleflex.com/user-78745-avatar.jpg](https://samples.scaleflex.com/user-78745-avatar.jpg)                       |
| ![](/files/zqekVKaOHzVuXmZQVSrr) | [/samples.scaleflex.com/user-78745-avatar.jpg](http://doc.cloudimg.io/https://samples.scaleflex.com/user-78745-avatar.jpg) |

### Extending and overriding rules <a href="#od_4e707f6b" id="od_4e707f6b"></a>

You can add additional operations together with a preset. If an operation or a filter already exists, the value provided in the URL will take precedence over the one in the rule. Here is an example:

| Rule pattern | Operations and filters                                                                                                                                                                       |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -avatar.jpg  | <mark style="color:orange;">**func=crop**</mark>&<mark style="color:orange;">**w=300**</mark>&<mark style="color:orange;">**h=300**</mark>&<mark style="color:orange;">**radius=max**</mark> |

Adding more parameters or overriding some of the parameters from above:

| Preview                          | Syntax                                                                                                                                                                                 |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](/files/k3sQz8Hw4EPMzOFLQpm3) | [/samples.scaleflex.com/user-78745-avatar.jpg?<mark style="color:green;">**gray=1**</mark>](https://doc.cloudimg.io/https://samples.scaleflex.com/user-78745-avatar.jpg?gray=1)        |
| ![](/files/18Pnjk1ASzAThYaQQPxJ) | [/samples.scaleflex.com/user-78745-avatar.jpg?<mark style="color:orange;">**radius=50**</mark>](https://doc.cloudimg.io/https://samples.scaleflex.com/user-78745-avatar.jpg?radius=50) |
