Compress image
image_compressCompress image files by re-encoding at a chosen quality or target size, optionally resizing the longest side and converting between JPEG, WebP, AVIF, or PNG.
Instructions
Make an image file smaller: re-encode at a quality (default 80) and optionally cap the longest side (maxSide), as JPEG, WebP, AVIF or PNG ("keep" = same format; GIF/BMP/TIFF become PNG). Or give targetBytes to find the highest quality that fits that size. With keepSmaller (default on) the original is kept when re-encoding would not make it smaller. Reports before/after sizes and % saved. Transparent areas become white in JPEG. Metadata (EXIF, GPS) is not copied. PNG is lossless (quality ignored). Web version: https://s3eidat.github.io/image-squeeze/
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | The image: a local file path (absolute, or relative to the server's --root) or base64 data (raw or a data: URI). | |
| format | No | Output format. Default keep (same as the input). | keep |
| output | No | Where to write the result: a file path, or a folder ending in "/". Default: the server output folder (a temp folder unless --out-dir is set). | |
| maxSide | No | Scale down so the longest side is at most this many pixels (e.g. 1920). | |
| quality | No | Quality 1-100 for JPEG / WebP / AVIF. Default 80 (website default). | |
| keepSmaller | No | Keep the original bytes when the result would be larger (same format and size only). Default true. | |
| targetBytes | No | Aim for a file of at most this many bytes: searches the highest quality that fits (lossy formats only; overrides quality). | |
| returnBase64 | No | Also return the output as base64 in the result (only for small files). Default false. |