# Presets

## Crop

Keeps only a specific region of the image, and removes the rest.

| Name |   |
| ---- | - |

| width | <p><strong>Type</strong>: number</p><p><strong>Default:</strong> Width of the image</p> |
| ----- | --------------------------------------------------------------------------------------- |

| height | <p><strong>Type:</strong> number</p><p><strong>Default:</strong> Height of the image</p> |
| ------ | ---------------------------------------------------------------------------------------- |

\| gravity | <p><strong>Type:</strong> string</p><p><strong>Default:</strong> center</p><p>center | northwest | north |</p><p>northeast | east | southeast |</p><p>south | southwest | west</p> |
\| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

{% hint style="info" %}
Crop requires at least **width** or **height** is required for a crop operation.
{% endhint %}

### Example

Crop an image to 200x200 pixels and center the image on the largest face in the picture.

{% code title="config.yml" %}

```yaml
presets:
  crop_200x200_face:
    steps:
      - $crop:
          width: 200
          height: 200
          gravity: face
```

{% endcode %}

Crop so that the image fits within a 200 pixels width and keep height from the original.

{% code title="config.yml" %}

```
presets:
  crop_200_width:
    steps:
      - $crop:
          width: 200
```

{% endcode %}

## Fit

Fits the image into a box. Keeps aspect ratio and does not remove any parts of the image.

| Name |   |
| ---- | - |

| width | <p><strong>Type:</strong> number</p><p><strong>Default:</strong> Width of the image</p> |
| ----- | --------------------------------------------------------------------------------------- |

| height | <p><strong>Type:</strong> number</p><p><strong>Default:</strong> Height of the image</p> |
| ------ | ---------------------------------------------------------------------------------------- |

{% hint style="info" %}
Fit requires at least **width** or **height** is required for a crop operation.
{% endhint %}

### Example

Fit an image within 200x200 pixels large area and keep aspect ratio.

{% code title="config.yml" %}

```
presets:
  fit_200x200:
    steps:
      - $fit:
          width: 200
          height: 200
```

{% endcode %}

## Fill

Resizes the image to fill a bounding box. **With aspect ratio intact** and will remove parts of the image that are outside the box. Use gravity to move the image within the bounding box.

| Name |   |
| ---- | - |

| width | <p><strong>Type:</strong> number</p><p><strong>Required</strong></p> |
| ----- | -------------------------------------------------------------------- |

| height | <p><strong>Type:</strong> number</p><p><strong>Required</strong></p> |
| ------ | -------------------------------------------------------------------- |

\| gravity | <p><strong>Type</strong>: string</p><p><strong>Default:</strong> center</p><p>center | northwest | north |</p><p>northeast | east | southeast |</p><p>south | southwest | west</p> |
\| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

{% hint style="info" %}
Fill will not scale up images if they are smaller than the defined width and height of the preset.
{% endhint %}

### Example

Creates an image with 200x200 pixels size and any bleeding pixels are cut off, if there is faces in the picture, center on the largest one found.

{% code title="config.yml" %}

```yaml
presets:
  fill_200x200_face:
    steps:
      - $fill:
          width: 200
          height: 200
          gravity: face
```

{% endcode %}

## Resize

Resizes images to the exact dimension specified, **without** keeping aspect ratio, and does not remove any part of the image.

| Name |   |
| ---- | - |

| width | <p><strong>Type:</strong> number</p><p><strong>Required</strong></p> |
| ----- | -------------------------------------------------------------------- |

| height | <p><strong>Type:</strong> number</p><p><strong>Required</strong></p> |
| ------ | -------------------------------------------------------------------- |

Resizes images to the exact dimension of 200x200 pixels.

{% code title="config.yml" %}

```yaml
presets:
  resize_200x200:
    steps:
      - $resize:
          width: 200
          height: 200
```

{% endcode %}

## Rotate

Rotates images to the angle specified or auto-rotate to correct orientation, will scale up and crop any bleed after rotation.

| Name |   |
| ---- | - |

\| angle |   | <p><strong>Type</strong>: number | 'auto'</p><p><strong>Default:</strong> 0</p><p>-180 - 180 | auto</p> |
\| ----- | - | ------------------------------------------------------------------------------------------------------- |

Rotate image to correct orientation.

{% code title="config.yml" %}

```yaml
presets:
  rotate_200x200_auto:
    steps:
      - $rotate:
          angle: auto
```

{% endcode %}

Rotate image, scale up and crop bleed.

{% code title="config.yml" %}

```yaml
presets:
  rotate_200x200_15:
    steps:
      - $rotate:
          angle: 15
```

{% endcode %}

## Format

Changes the format of the image. Conversion is implemented between all of SpaceChops supported formats.

| Name |   |
| ---- | - |

\| type | <p><strong>Type:</strong> string</p><p><strong>Required</strong></p><p>jpeg | png | gif | webp</p> |
\| ---- | -------------------------------------------------------------------------------------------------- |

Fill the area of 200x200 pixels with the image and format to jpeg if the original is another type.

{% code title="config.yml" %}

```yaml
presets:
  fill_200x200:
    steps:
      - $fill:
          width: 200
          height: 200
      - $format:
          type: jpeg
```

{% endcode %}

## Compress

Compresses the image (but does not strip metadata). If used together with Format, Compress should be placed after Format as it depends on the filetype.

| Name |   |
| ---- | - |

| quality | <p><strong>Type</strong>: number</p><p><strong>Default:</strong> 100</p> |
| ------- | ------------------------------------------------------------------------ |

| lossy | <p><strong>Type:</strong> boolean</p><p><strong>Default:</strong> false</p> |
| ----- | --------------------------------------------------------------------------- |

Fill an area of 200x200 pixels and compress the image using mozjpeg to a quality of 82, to make the images fast and **SEO friendly**.

{% code title="config.yml" %}

```yaml
presets:
  fill_200x200:
    steps:
      - $fill:
          width: 200
          height: 200
      - $format:
          type: jpeg
      - $compress:
          quality: 82
```

{% endcode %}

## Strip

Strips the image of all EXIF data.

> Exif data is nowadays often quite large, and for images to be fast to load this should be removed.

| Name |   |
| ---- | - |

| icc\_profile | <p>Should the ICC Profile be kept<br></p><p><strong>Type:</strong> boolean</p><p><strong>Default:</strong> true</p> |
| ------------ | ------------------------------------------------------------------------------------------------------------------- |

{% hint style="info" %}
Do avoid removing icc\_profile, your images will look different on different types of screens.
{% endhint %}

### Example

Fill an area of 200x200 pixels and strip all exif data so that the resulting image becomes fast to load and small in byte size. We also want to keep all the colors as they were made from the original.

{% code title="config.yml" %}

```yaml
presets:
  fill_200x200:
    steps:
      - $fill:
          width: 200
          height: 200
      - $strip:
          icc_profile: jpeg
```

{% endcode %}


---

# 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://spacechop.gitbook.io/spacechop/configuration/presets.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.
