Optimize
Compress one or more images without resizing them. Supports lossless and lossy modes, and can optionally produce a WebP copy alongside each compressed original.Parameters
Must be
"optimize".Array of input file paths to optimize.
Directory where optimized files will be written.
Optimization level.
| Value | Description |
|---|---|
lossless | Maximum quality, moderate file size reduction |
lossy | Smaller files with configurable quality loss |
Encode quality when
level is "lossy". Range: 1–100.When
true, each input also produces a .webp sibling file in output_dir. Useful for serving modern formats with a fallback.Go client
also_webp: true by default. For full control, use Client.Execute() with an OptimizeJob:
Examples
Go examples
Convert
Re-encode a single image to a different format. Optionally resize the output in the same pass by providingwidth and/or height.
Parameters
Must be
"convert".Path to the source image.
Path for the converted output file, including the new extension.
Target format. See the supported formats table below.
Encode quality for lossy formats (JPEG, WebP, AVIF). Range: 1–100.
Output width in pixels. When provided alongside
height, the image is resized during conversion. When provided alone, aspect ratio is preserved.Output height in pixels. Follows the same aspect-ratio rules as
width.When
true, the output is also returned as a base64-encoded string in data_base64.Supported formats
| Format | format value | Notes |
|---|---|---|
| PNG | png | Lossless |
| JPEG | jpeg or jpg | Lossy |
| WebP | webp | Lossy or lossless depending on quality |
| AVIF | avif | High efficiency, lossy |
| GIF | gif | Paletted, 256 colors |
| ICO | ico | Windows icon format |
Go client
Client.Execute() with a ConvertJob:
Examples
Go examples