compress_image · 1 credit · webp / jpeg / png

The cheapest call on the platform is the one that makes your site fast.

A 4K generation is a beautiful asset and a terrible download. One credit re-encodes it at a quality you choose, in a format you choose, and hands back a hosted URL you can ship.

Typical page weight

4K PNG, straight from upscaleheavy
Same image, WebP @ 75a fraction of it

Exact ratios depend entirely on the image — flat illustration compresses far harder than grainy photography. Run it on your own assets and read the numbers rather than trusting a marketing figure.

Quality is a decision, not a default

The single biggest win in image performance is not a clever encoder — it is admitting that a 48-pixel avatar does not need the same quality budget as a full-bleed hero.

85–95

Hero images, product photography, anything a visitor zooms into.

Modest savings, no visible artefacts.

70–80

Body imagery, blog figures, card art. The default sits here.

The usual sweet spot for the web.

50–65

Thumbnails, avatars, list rows, anything under 200px.

Large savings; artefacts hidden by the small render size.

10–45

Placeholders and blurred previews loaded before the real asset.

Deliberately rough — these are meant to be replaced.

Two fields worth setting

imagerequired

A public https URL or a base64 data URI — including the URL another tool just returned.

quality10–95, default 70

The encoder quality percentage. Lower means smaller and softer.

targetFormatwebp · jpeg · png

Defaults to webp. Pick png only when the alpha channel has to survive.

⚠️ Alpha and JPEG do not mix

Compressing a transparent cutout to JPEG flattens the alpha onto a solid ground — usually black. If the source has transparency, target WebP or PNG.

compress every asset in a batch
{
  "name": "multicall",
  "arguments": {
    "requests": [
      { "tool": "compress_image",
        "args": { "image": "…/hero.png",
                  "quality": 82,
                  "targetFormat": "webp" } },
      { "tool": "compress_image",
        "args": { "image": "…/card-01.png",
                  "quality": 70,
                  "targetFormat": "webp" } },
      { "tool": "compress_image",
        "args": { "image": "…/avatar.png",
                  "quality": 55,
                  "targetFormat": "webp" } }
    ]
  }
}
three images · three credits · one round trip

Why an agent should compress before it commits

Largest Contentful Paint

On most content pages the LCP element is an image. Its transfer size is the single lever with the most effect on that number, and it is a lever you can pull automatically.

Repository hygiene

An agent that generates assets straight into a repo can leave megabytes of PNG behind. A compress step before the write keeps the diff reviewable and the clone fast.

Bandwidth you pay for

Every uncompressed hero is served to every visitor. One credit spent once beats the same bytes shipped a hundred thousand times.

Compression API questions

What quality setting should I use?

The default of 70 is a good starting point for photography on the web. Push to 80–85 for hero images and product shots where artefacts would be noticed; drop to 50–60 for thumbnails, avatars and anything rendered small. The accepted range is 10 to 95.

Which output formats can I compress to?

WebP (the default), JPEG and PNG. WebP is the right answer for almost every photograph on the web; JPEG when a consumer needs maximum compatibility; PNG when transparency has to survive, since JPEG has no alpha channel.

Is compression lossy?

For WebP and JPEG at any quality below 100, yes — that is where the savings come from. Encoding to PNG is lossless, so it shrinks far less; if a file has to stay pixel-identical, use PNG and expect modest gains.

How is this different from convert_format?

compress_image is about file size: you set a quality percentage and it re-encodes. convert_format is about the container: it moves an image between PNG, JPG, WebP, GIF, TIFF and AVIF without a quality dial. Reach for compression when the file is too heavy, conversion when the format is wrong.

Does it cost the same regardless of image size?

Yes — 1 credit per call, flat. Compression runs on our own infrastructure rather than a model provider, which is why it is the cheapest tool on the platform and safe to run over every asset in a pipeline.