> ## Documentation Index
> Fetch the complete documentation index at: https://learn.workflow.dog/llms.txt
> Use this file to discover all available pages before exploring further.

# Resize Image

> Resize an image in pixels or as a percentage with configurable fit behavior.

**Resize Image** changes an image's dimensions. Provide either width, height,
or both; when only one dimension is present, the original aspect ratio is
preserved.

## Inputs

| Input          | Type                     | Required      | Description                                                                 |
| -------------- | ------------------------ | ------------- | --------------------------------------------------------------------------- |
| **Image**      | File                     | Yes           | The image to resize.                                                        |
| **Unit**       | `pixels` or `percentage` | Yes           | How width and height are interpreted. Defaults to `pixels`.                 |
| **Width**      | Positive number          | No            | Target width in pixels or as a percentage of original width.                |
| **Height**     | Positive number          | No            | Target height in pixels or as a percentage of original height.              |
| **Fit**        | Enum                     | Yes           | How the source fits when both dimensions are supplied. Defaults to `cover`. |
| **Position**   | Enum                     | Sometimes     | Alignment for `cover` or `contain`. Defaults to `center`.                   |
| **Background** | String                   | For `contain` | Color used to fill empty space. Defaults to `#000000`.                      |

Percentage dimensions are converted from the source metadata and rounded down
to whole pixels. For example, width `50` means half of the original width.

### Fit modes

| Fit       | Behavior                                                                                   |
| --------- | ------------------------------------------------------------------------------------------ |
| `cover`   | Fills both target dimensions, cropping overflow as needed.                                 |
| `contain` | Fits the whole image inside the target and fills remaining space with **Background**.      |
| `fill`    | Stretches the image to exactly the requested dimensions, even if the aspect ratio changes. |
| `inside`  | Preserves aspect ratio and stays within both target dimensions.                            |
| `outside` | Preserves aspect ratio while meeting or exceeding both target dimensions.                  |

**Position** offers top, bottom, left, right, corner, and center alignment for
the crop or padding created by `cover` and `contain`.

## Output

| Output            | Type | Description                                                 |
| ----------------- | ---- | ----------------------------------------------------------- |
| **Resized Image** | File | The resized image, preserving the input name and MIME type. |

## Examples

* Set width to `1200`, leave height empty, and use pixels to make a
  1200-pixel-wide image without changing its proportions.
* Set width and height to `50` with percentage units to halve both dimensions.
* Set `1080` by `1080` with `cover` to create a square crop, or `contain` to
  retain the whole source inside a square canvas.

<Warning>
  If both width and height are empty, the action has no target size. Provide at
  least one dimension for predictable output.
</Warning>
