imagepeek: compress an image (optionally to a byte budget)
image_compressCompress an image to a smaller JPEG, WebP, AVIF or PNG, with metadata stripped. Set a quality or max_bytes target to get the highest quality that fits.
Instructions
imagepeek: Compress an image, optionally to a byte budget. To change the format only use image_convert. Returns a smaller JPEG, WebP, AVIF or PNG with metadata stripped: at quality, or with max_bytes the highest quality that fits (target_met false when none does); PNG can be quantised to colors. It never returns a larger file (the original comes back with returned_original: true). Reads PNG, JPEG, WebP, GIF, TIFF, BMP, ICO and AVIF; other formats and images over 40 megapixels are refused (not charged). Output: base64 data_base64, without EXIF, GPS, XMP or IPTC; over 15 MB or 50 megapixels is a 413 (not charged). Images are not logged; a result is kept only with output "url" (24 h). Typically 0.5-2 s. Price: USD 0.003. Free: 3 imagepeek calls per IP per UTC day. Docs: https://tanod.dev/learn/image-compress-api.html
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Public http(s) URL of the image (at most 10 MB; private, internal and IP-literal hosts are refused); or use image_base64. | |
| colors | No | png: quantise to this many colours. | |
| format | No | Output format: jpeg, png, webp or avif (default: the input's). | |
| output | No | base64 (default): the file comes back inline as base64. url: the file is stored for 24 hours and the reply carries a download link (url, expires_at, bytes, content_type, sha256) instead of the base64, which keeps the file out of your context window. | base64 |
| quality | No | Target (or, with max_bytes, highest) quality. | |
| keep_icc | No | Keep the ICC colour profile (default true). | |
| lossless | No | webp only: lossless encoding (default false). | |
| max_bytes | No | Size target: the highest quality that fits. | |
| auto_orient | No | Apply the EXIF orientation first (default true). | |
| progressive | No | jpeg only: progressive encoding (default false). | |
| image_base64 | No | The image as standard or url-safe base64 (at most 10 MB decoded; a data:image/...;base64, prefix is fine); or use url. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | ||
| bytes | No | ||
| error | No | Only on an error result: an object {code, message}, or the reason string of an x402 PaymentRequired object. | |
| input | No | ||
| notes | No | ||
| width | No | ||
| format | No | ||
| height | No | ||
| sha256 | No | ||
| source | No | ||
| encodes | No | ||
| final_url | No | ||
| operation | No | ||
| expires_at | No | ||
| source_url | No | ||
| target_met | No | ||
| after_bytes | No | ||
| data_base64 | No | ||
| saved_bytes | No | ||
| saved_ratio | No | ||
| before_bytes | No | ||
| content_type | No | ||
| quality_used | No | ||
| returned_original | No |