Compress an image
compress_imageMake an image file smaller. Keeps the format unless format is given. Set target_bytes to hit an exact file size (e.g. 100000 for 100 KB). Otherwise mode decides: smart (default) finds the smallest file that still looks like the original, quality uses quality (1-100), lossless keeps every pixel (PNG, WebP, AVIF, TIFF only), keep does not compress: the image comes back as it was with only its metadata removed. Reads JPEG, PNG, WebP, AVIF, GIF, TIFF and SVG. Returns a download URL valid for one hour.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Default: smart, or quality when `quality` is given. | |
| format | No | Output format. Default: auto (keep the input format). | |
| rotate | No | Degrees clockwise. Not a quarter turn: the corners the turn adds are transparent (or the background colour in JPEG and BMP). | |
| quality | No | ||
| image_url | No | Public http(s) address of the image. Use this or image_base64. | |
| max_width | No | Resize to fit this width; never enlarges. | |
| crop_ratio | No | Crop to this shape first, e.g. "1:1" or "16:9", keeping the subject in frame. | |
| max_height | No | Resize to fit this height; never enlarges. | |
| image_base64 | No | The image file's bytes, base64-encoded. Use for a local file, e.g. one in the repository. | |
| target_bytes | No | Compress to at most this many bytes. |