compress_image
Re-encode a single raster image to webp, jpeg, png or avif, optionally resizing it and/or converting it to grayscale. HEIC/HEIF input is converted to JPEG first, and SVG input is rasterised at 300 DPI, fitted inside 800x800 unless width or height is given. Lossy for webp, jpeg and avif at any quality below 1.0. Raster images only: a PDF or a video is rejected, and neither can be re-encoded anywhere on this server. Output shape depends on size: an input under 5MB is processed in-app and the encoded image bytes are returned, while anything larger is sent to razi.pro's worker and the reply is JSON { url, size, metadata } pointing at a hosted copy instead of bytes. Paid compute; 30 calls per hour per IP. There is no upload channel over MCP: pass fileUrl, a URL in razi.pro's own storage; third-party URLs are rejected. Obtain one by uploading the image over the REST API first (POST /api/v1/tools/execute with the file attached).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | No | Target width in pixels. Give only one of width/height to scale the other proportionally. Omit both to keep the original dimensions. Enlarging is allowed. | |
| format | No | Output container/codec. Default webp; an unrecognised value also falls back to webp. Transparency survives in webp, png and avif but not jpeg. | |
| height | No | Target height in pixels. Give only one of width/height to scale the other proportionally. Omit both to keep the original dimensions. | |
| quality | No | Encoder quality as a fraction from 0.1 to 1.0, scaled to the encoder's 0-100 range. Default 0.9. Higher means larger and closer to the original. | |
| grayscale | No | Drop colour before encoding. Default false. | |
| keepAspectRatio | No | Only has an effect when BOTH width and height are given. Default false, which centre-crops the image to fill the box exactly. Set true to fit the whole image inside the box instead, so the result may be smaller than the box in one dimension. |