Compress images
compress_imagesCompress, convert or resize images. Send public image addresses in urls, uploads made with create_upload_link in upload_ids, or small files inline as base64 in files. Each image counts one against the account's daily images and compressions a minute, the same as on the website. Images are queued and compress in the background, usually in a few seconds: call get_image with each id until its status is completed, already-optimized, failed or cancelled, then download it from its download_url. Each image also gets an AI alt text and a suggested file name unless alt_text is false; they arrive in alt_text a few seconds after the image is completed or already-optimized. One call takes up to 20 images across urls, upload_ids and files; send the rest in another.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "compress_images"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| urls | No | Public http or https addresses of images to fetch. Iminify refuses private networks, follows up to five redirects and names each file after its address. | |
| files | No | Small files sent inline, up to 4 MB each. Use create_upload_link for anything bigger. | |
| level | No | How hard to compress. "smart" (the default) finds the lowest quality that still looks like the original; "ultra" goes further and softens fine texture a little; "lossless" changes no pixel unless a size_limit needs it to; "none" only converts, resizes, fits a size limit and strips metadata. | |
| scale | No | Resize to this percentage of the original, 1 to 100. Not together with width or height. Like width, it is refused for an animated WebP or PNG. | |
| width | No | Resize to this width in pixels. Alone, the height follows the aspect ratio; with height too, the image is resized to exactly that size. An animated WebP or PNG cannot be resized and is refused with animation_not_resizable; an animated GIF can. | |
| folder | No | Paid plans: the folder every image of this call belongs in, like "holiday/beach", so create_zip puts them there. Send each folder's images in a call of their own. On another plan the call is refused with pro_required. | |
| format | No | Convert to this format. "auto" encodes every format that can hold the image and keeps the smallest. Leave it out to keep each image's own format (a HEIC or TIFF always comes back in another one). | |
| height | No | Resize to this height in pixels, the same way as width. | |
| alt_text | No | Write an alt text and a suggested file name for each image with AI. On by default; false leaves it out. They arrive a few seconds after the image finishes, each counting against the account's daily AI alt texts; once those are used up the images still compress, without one. | |
| size_limit | No | The most each optimized file may weigh, in KB of 1,000 bytes, for a form or a page with a file size limit ("under 100 KB" is 100). Iminify lowers the quality until it fits, and makes the image smaller in pixels when the lowest quality is still over. The limit comes before the level: under "lossless" or "none", a file over it is encoded again with loss. A PNG or GIF kept in its own format that is over the limit comes back as JPG, WebP or AVIF, so format "png" is refused with it; animations are never fitted. Each finished image's size_limit_status says under, resized or over. | |
| upload_ids | No | Upload ids from create_upload_link whose file has been sent. Each upload can be compressed once. | |
| keep_metadata | No | Keep the EXIF metadata (camera, date, location). Off by default, which strips it; the orientation is applied to the pixels first. | |
| alt_text_language | No | The language to write the alt text in, as a language tag. English ("en") by default. The suggested file name follows it for languages written in the Latin alphabet and is in English otherwise. | |
| responsive_widths | No | Paid plans: also make each image at these widths in pixels, for an <img srcset>, like [480, 768, 1200, 1600], the website's default. Each width is made from the original, at the same level and in the delivered format, and never enlarged: one wider than the image is made at its own width, once. They are made a few seconds after the image finishes; responsive on the image lists them. On another plan the call is refused with pro_required. | |
| use_suggested_name | No | Rename the optimized copy to the suggested file name as soon as the alt text arrives, unless it already has a new name by then. Off by default. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| next | No | ||
| images | No | The images queued. | |
| refused | No | The sources refused, each with the reason. | |
| not_started | No | Addresses not fetched because the call ran out of time. | |
| not_started_note | No |