> 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

Apply transformation rules based on url pattern

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="https://727245914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIDIcmPiz7q6Sr6ZHHQxV%2Fuploads%2F9jFOUEoak80LZ1L5NGk1%2FRules.png?alt=media&amp;token=d4a44c1e-1efd-49e1-a40a-3f4d619e58e7" 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                                                                                                                     |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/5VrfsaejqN7f1nwxIR2E/image.png) | [//samples.scaleflex.com/user-78745-avatar.jpg](https://samples.scaleflex.com/user-78745-avatar.jpg)                       |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/diPBrcsjtYzkwHeOHNmv/image.png) | [/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                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/Una9ALIA3SBWoHd8kAdp/image.png) | [/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)        |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/ufKboFgM54ReHjz5dTm1/image.png) | [/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) |
