# 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) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudimage.io/setup/shortening-urls/rules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
