Resize image
resize_imageResize PNG, JPEG, WebP, or AVIF images by width, height, or scale. Write the resized image to a new file next to the original or to a specified output path.
Instructions
Resize a PNG, JPEG, WebP, or AVIF image with Tinify.dev by width, height, or scale, and write the result next to the original (or to output_path). At least one of width, height, or scale is required. The source image is never overwritten silently.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the image (png, jpg, jpeg, webp, avif; max 40 MB). | |
| scale | No | Scale factor, e.g. 0.5 halves both dimensions. | |
| width | No | Target width in pixels. | |
| height | No | Target height in pixels. | |
| 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. | |
| keep_aspect_ratio | 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. |