Shrink an image or video for the web without visible loss
media_optimizeOptimize images and videos for web uploads: convert images to WebP/JPEG/PNG and videos to H.264 faststart, shrinking file size to an SSIM quality target while keeping originals untouched.
Instructions
Images to WebP by default, or JPEG/PNG with format (or a .jpg/.png output_path), for places like LinkedIn post uploads that don't take WebP. Videos to H.264 with faststart. Raises quality until SSIM (similarity to the original) reaches the target, so the size drops but the picture does not visibly change. The original is kept untouched. Behaviour notice: by default the output has embedded metadata stripped (EXIF, XMP, C2PA content credentials, text chunks), like most web image optimizers; the result lists what was removed. Pass keep_metadata: true to keep what re-encoding can carry. Invisible watermarks such as SynthID are never touched.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Image output format. Default: from output_path's extension, else webp | |
| max_width | No | ||
| overwrite | No | ||
| input_path | Yes | ||
| keep_audio | No | ||
| output_path | No | Default: same folder, .webp for images (or the chosen format), -web.mp4 for videos | |
| keep_metadata | No | true: don't strip embedded metadata from the output (EXIF/XMP/C2PA). Default follows config strip_ai_metadata (on). |