# Aspect ratio crop

Sets target aspect ratio or aspect ratio range when cropping. Aspect ratios can be set as decimal values (1.778) or ratios (16:9).

<mark style="color:orange;">**aspect\_ratio=AR**</mark> | <mark style="color:orange;">**ar=AR**</mark>

<mark style="color:orange;">**aspect\_ratio=AR1,AR2**</mark> | <mark style="color:orange;">**ar=AR1,AR2**</mark>

## **Crop and resize**

If you provide only one dimension parameter (**width** or **height**) and **aspect\_ratio**, the other dimension will be calculated. If you include both **width** and **height** in the URL, **aspect\_ratio** is ignored.

### Examples

|                                  |                                                                                                                                                                                                                                                                                                    |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](/files/WJO5C08Pea3dwSQRiClK) | <p>Original aspect ratio (3:2 or 1.5):<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/car1.jpg?w=400">/samples.scaleflex.com/car1.jpg?<mark style="color:orange;"><strong>w=400</strong></mark></a></p>                                                                         |
| ![](/files/JjCdye6hqU6LMCapBDU5) | <p>Cropped to 1.8:<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/car1.jpg?w=400&#x26;aspect_ratio=1.8">/samples.scaleflex.com/car1.jpg?<mark style="color:orange;"><strong>w=400</strong></mark>&<mark style="color:orange;"><strong>aspect\_ratio=1.8</strong></mark></a></p> |

## Crop without resize <a href="#od_46b79893" id="od_46b79893"></a>

If you provide only **aspect\_ratio** and no dimensions (**width** or **height**), the image will be cropped without resizing.

### Examples

| Preview                          | Syntax                                                                                                                                                                                                                              |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](/files/HDq5lk0K0gFFdqaSaCtN) | <p>Original aspect ratio (1.323):<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/frog.png">/samples.scaleflex.com/frog.png</a></p>                                                                               |
| ![](/files/wgss6O4uzD18VrKGQw75) | <p>Cropped to 3:2 (1.5):<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/frog.png?aspect_ratio=3:2">/samples.scaleflex.com/frog.png?<mark style="color:orange;"><strong>aspect\_ratio=3:2</strong></mark></a></p> |

## Aspect ratio range <a href="#od_e014a40a" id="od_e014a40a"></a>

You can specify a range of aspect ratio values, for example, **aspect\_ratio=4:3,16:9**. Images that fall within this range, will not be cropped. Useful to avoid very wide or very tall images by cropping them to the closest aspect ratio.

### Examples

|                                  |                                                                                                                                                                                                                                                                                                                                        |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](/files/rtYMJtA2ZQkUnYMo8t2v) | <p>Original aspect ratio 1.5:<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/car1.jpg?w=400">/samples.scaleflex.com/car1.jpg?<mark style="color:orange;"><strong>w=400</strong></mark></a></p>                                                                                                                      |
| ![](/files/sg8tYcpNiQCZijnx96sy) | <p>Aspect ratio range 1.5..2 (no crop needed):<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/car1.jpg?w=400&#x26;aspect_ratio=1.5,2.0">/samples.scaleflex.com/car1.jpg?<mark style="color:orange;"><strong>w=400</strong></mark>&<mark style="color:orange;"><strong>aspect\_ratio=1.5,2.0</strong></mark></a></p> |
| ![](/files/jfoJI43W2N8dZNIxX3i5) | <p>Original aspect ratio 2.25:1 (2.25):<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/kids.jpg?w=400">/samples.scaleflex.com/kids.jpg?<mark style="color:orange;"><strong>w=400</strong></mark></a></p>                                                                                                            |
| ![](/files/MqgqElrVeryuDkuqCgdi) | <p>Aspect ratio range 3:2..2:1 (1.5..2):<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/kids.jpg?w=400&#x26;aspect_ratio=3:2,2:1">/samples.scaleflex.com/kids.jpg?<mark style="color:orange;"><strong>w=400</strong></mark>&<mark style="color:orange;"><strong>aspect\_ratio=3:2,2:1</strong></mark></a></p>       |


---

# 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/transformations/image-operations/crop/aspect-ratio-crop.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.
