Optimise images
optimize_imagesOptimise images like an expert, deciding per image. Default policy "auto" writes WebP, which every current browser supports: lossy for photos, lossless or palette for screenshots and graphics, whichever is smallest at the visual target.
Instructions
Optimise images like an expert, deciding per image. Default policy "auto" writes WebP, which every current browser supports: lossy for photos, lossless or palette for screenshots and graphics, whichever is smallest at the visual target. policy "avif" also tries AVIF (smaller, needs Safari 16.4+); "picture" adds a JPEG/PNG fallback; "keep" keeps the source format. Resizing fits each image's own aspect ratio and never upscales; widths makes srcset sizes; crop makes exact shapes. Writes NEW files to "/optimized/" (or outputDir), never touching originals; re-runs skip unchanged files. Works up to 45s, then returns status "running" with a jobId: call get_job to wait for the rest. Use dryRun: true to preview decisions without encoding. Allowed directories: (none configured).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| crop | No | Exact output shape (e.g. 400x400 thumbnails). attention keeps faces/salient areas; entropy keeps the busiest area. | |
| files | No | Per-file settings that override the top-level ones, e.g. [{ path: "hero.jpg", resize: { maxWidth: 1920 }, priority: true }]. | |
| limit | No | Items per page in the result. | |
| paths | No | Files, folders or globs to optimise with the top-level settings. | |
| dryRun | No | Return the per-image plan (class, candidates, sizes, output paths) without encoding anything. | |
| offset | No | First item of the page to return (use nextOffset from the previous result). | |
| policy | No | auto (default): WebP (lossy, lossless or palette, whichever is smallest at the target); works in every current browser. avif: AVIF or WebP, whichever is smaller (often 20–30% smaller photos; AVIF needs Safari 16.4+). keep: same format as the source. picture: AVIF/WebP plus a JPEG/PNG fallback for <picture>. | |
| resize | No | Fit inside this box, keeping the aspect ratio. Never upscales. | |
| target | No | Visual-quality target (SSIMULACRA 2). Presets for photos: small=65, balanced=75 (default), high=85, lossless-look=90; screenshots, graphics and icons get +10 (faint UI lines need it). Or an exact number 30–100 for every image. | |
| widths | No | Responsive widths for srcset. "auto" = 640/960/1280/1920/2560 up to the image's own width. Files get a -<w>w suffix. | |
| urlBase | No | URL prefix for generated markup, e.g. "/images/optimized". | |
| metadata | No | strip (default): remove EXIF/GPS/XMP after auto-rotating. all: keep metadata. | |
| priority | No | Markup only: above-the-fold image (loading="eager", fetchpriority="high"). | |
| outputDir | No | Default: an "optimized" folder inside each input folder, mirroring its structure. | |
| response_format | No | detailed adds per-output scores, qualities and HTML markup. | concise |