Optimize / convert an image for the web
optimize_imageFetch an image from a public URL and re-encode it smaller (WebP/AVIF/JPEG). Optionally resize to a target width to reduce file size for shipping assets.
Instructions
Fetch an image from a public URL and re-encode it smaller (WebP/AVIF/JPEG), optionally resizing to a target width. Returns the optimized image plus before/after byte sizes. Use this when an AI-generated or dropped-in asset (hero image, screenshot, illustration) is too large to ship.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | No | Resize to this width in px, preserving aspect ratio. Omit to keep original size. | |
| format | No | Output format. webp = best browser support; avif = smallest; jpeg = universal. | webp |
| quality | No | Encode quality 1-100 (80 is a good default). | |
| image_url | Yes | Public URL of the source image (PNG/JPEG/WebP/AVIF/GIF). |