Crop image
image_cropCrop images to a pixel box or common aspect ratio, with centered or edge-aligned positioning, and save as JPEG, PNG, WebP, or AVIF.
Instructions
Crop an image to a pixel box (x, y, width, height) or to an aspect ratio (1:1, 4:5, 3:2, 16:9, 9:16, "W:H" or a number), taking the largest centred region (or aligned to an edge with position). Boxes are kept inside the image. Output JPEG/PNG/WebP/AVIF, name -x.. Web version: https://s3eidat.github.io/image-resize/
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | Left edge of the crop box (pixels). Use with y, width, height. | |
| y | No | Top edge of the crop box (pixels). | |
| image | Yes | The image: a local file path (absolute, or relative to the server's --root) or base64 data (raw or a data: URI). | |
| ratio | No | Aspect ratio as "W:H" (e.g. "1:1", "4:5", "3:2", "16:9", "9:16"), a number (width/height), "orig" or "free". | |
| width | No | Width of the crop box (pixels). | |
| format | No | Output format. "keep" = same as the input when it is JPEG/PNG/WebP (else PNG). Default keep. | keep |
| height | No | Height of the crop box (pixels). | |
| output | No | Where to write the result: a file path, or a folder ending in "/". Default: the server output folder (a temp folder unless --out-dir is set). | |
| quality | No | Quality 1-100 for JPEG / WebP / AVIF (ignored for PNG). Default 90, same as the website. | |
| position | No | Where the ratio crop sits. Default center (the website default). | center |
| returnBase64 | No | Also return the output as base64 in the result (only for small files). Default false. |