compress_image
Compress an image
Re-encode an image with quality/format options to reduce file size. Supports jpeg, png, webp, tiff, gif. Instead of a q number you can set quality_target (0-1]: the smallest file with SSIM at or above the target, searched on the worker (jpeg, webp, avif; flat surcharge; outcome reported in X-Pictomancer-Quality-* headers). If the output is not smaller than the input, the request is free (X-Pig-Billed: 0) and does not consume free-tier quota. Optional enhancement modifiers: denoise (1-3), equalize, sharpen (applied denoise -> equalize -> op -> sharpen).
Responses:
200: Processed image binary (Success Response) Content-Type: application/json Content-Type: image/jpeg
Example Response:
"string"Content-Type: image/png
Example Response:
"string"Content-Type: image/webp
Example Response:
"string"Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | No | Quality (1-100). Lower = smaller file. Typical values: 60-80 for web, 85-95 for print. Maps to libvips Q parameter. | |
| strip | No | Strip metadata (EXIF, ICC profile, etc.) from the output. Reduces file size slightly. | |
| format | No | Output format: jpeg, png, webp, tiff, gif, or avif. If omitted, the original format is preserved. | |
| source | Yes | Image source: a public URL (https://...) or a base64-encoded string (optionally as a data URI like data:image/png;base64,...). | |
| autorot | No | Apply EXIF orientation before compressing. Opt-in; default false, which preserves current byte-for-byte behavior. | |
| denoise | No | Median denoise before compressing: radius 1-3 (window 3x3 to 7x7). Opt-in; no surcharge. | |
| sharpen | No | Unsharp-mask sharpen after compressing (libvips defaults). Opt-in. | |
| delivery | No | ||
| equalize | No | Auto-contrast (histogram equalisation of the value channel; hue and saturation preserved) before compressing. Opt-in. | |
| quality_target | No | Target SSIM (0-1]: the worker searches for the smallest file that still scores at least this. Alternative to q; mutually exclusive with it. Requires an explicit format among jpeg, webp, avif. Carries a flat surcharge for the extra encodes. |