compress
Re-encode an image to a new file at a chosen quality to reduce file size, returning bytes before/after and percent saved.
Instructions
Re-encode an image at a chosen quality to reduce file size, writing the result to a NEW file (source unchanged). Quality is 1-100 (default 80); lower values produce smaller files. The output format defaults to JPEG but can be set via 'format'. Returns the output path plus bytes_before, bytes_after, and saved_percent so you can see how much space was recovered.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| out | Yes | Output image path. A new file is created; the source is left untouched. | |
| path | Yes | Source image path. | |
| format | No | Optional output format (defaults to JPEG). Use PNG/WEBP to keep transparency. | |
| quality | No | Quality 1-100 (higher = larger, better). Default 80. |