Crop image
crop_imageCrop PNG, JPEG, WebP, or AVIF images to a specific rectangle using coordinates, and save the output without altering the original file.
Instructions
Crop a PNG, JPEG, WebP, or AVIF image with Tinify.dev to the given rectangle and write the result next to the original (or to output_path). The source image is never overwritten silently.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | Left edge of the crop rectangle in pixels. | |
| y | Yes | Top edge of the crop rectangle in pixels. | |
| path | Yes | Absolute path to the image (png, jpg, jpeg, webp, avif; max 40 MB). | |
| width | Yes | Crop width in pixels. | |
| height | Yes | Crop 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. |
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. |