Convert image format
convert_imageConvert an image to AVIF, WebP, JPEG, or PNG with Tinify. Outputs a .min file beside the original unless a custom output path is provided.
Instructions
Convert an image to AVIF, WebP, JPEG, or PNG with Tinify.dev (beta endpoint; may not be enabled on every account yet). Writes .min. next to the original unless output_path is given. Converting to the same format is rejected by the API (same_format_conversion).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the image (png, jpg, jpeg, webp, avif; max 40 MB). | |
| format | Yes | Target format. | |
| overwrite | No | Allow replacing an existing file at the output path. Default false. | |
| output_path | No | Absolute path to write the result. Default: <name>.min.<ext> next to the input. The source image is never overwritten unless output_path points at it AND overwrite is true. | |
| quality_mode | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | Yes | ||
| wrote | Yes | Whether a file was written. | |
| height | Yes | ||
| optimized | Yes | false when the API could not shrink the file and returned the original bytes; null when the concept does not apply (resize/crop). | |
| request_id | Yes | Quote this when contacting support. | |
| output_path | Yes | Where the result was written, or null when nothing was written. | |
| saved_bytes | Yes | original_bytes - result_bytes. | |
| result_bytes | Yes | Result size in bytes. | |
| change_percent | Yes | Byte change in percent; negative means smaller. | |
| original_bytes | Yes | Input size in bytes. |