# 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

|                                                                                                    |                                                                                                                                                                                                                                                                                                    |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/mNUMHz7wh2ycbBgxVQhJ/image.png) | <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>                                                                         |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/hW3XszzgSitrEWFxr9Qx/image.png) | <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                                                                                                                                                                                                                              |
| -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/ceH3ReecdqWlhqyXipPy/image.png) | <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>                                                                               |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/Igs5RRFxEx7iuYVznUpl/image.png) | <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

|                                                                                                    |                                                                                                                                                                                                                                                                                                                                        |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/L1cBWMFI05Krok9tA8Jd/image.png) | <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>                                                                                                                      |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/1M5Fa9arup9qOZJ343vf/image.png) | <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> |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/DjLlxIPHEpklIwdBTwMS/image.png) | <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>                                                                                                            |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/geGthtej1M2Rr6A5vjCh/image.png) | <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>       |
