compress
Shrink an image file to a target size by finding the highest quality that fits, or apply a quality value or preset. Converts between JPG, WebP, AVIF, and PNG while writing a new file.
Instructions
Make an image file smaller.
target_size='200KB' (or '1.5MB', or bytes): finds the highest quality that still fits, by searching (jpg/webp/avif) and tells you the result. If even min_quality cannot fit, it fails and says what is achievable, unless allow_downscale=true, which then shrinks the pixel dimensions step by step (reported). PNG is lossless: it is re-optimised, and lossy_png=true allows palette reduction (256 -> 16 colors) to reach a target. Without a target: quality=1-100, or preset high (88) / balanced (78) / small (60). format='webp' (or jpg/png) converts while compressing, e.g. a photo PNG to WebP. Output goes to photo.compressed.jpg unless output= is given; never overwrites unless overwrite=true. Warns if the result is not smaller than the input.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>"
},
"name": "compress"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| format | No | ||
| output | No | ||
| preset | No | balanced | |
| preview | No | ||
| quality | No | ||
| lossy_png | No | ||
| overwrite | No | ||
| allow_huge | No | ||
| min_quality | No | ||
| target_size | No | ||
| keep_metadata | No | ||
| allow_downscale | No |