The Tinify Webhook Proxy is a Cloudflare Worker that acts as a flexible proxy for the Tinify image compression API. It allows you to compress images using Tinify's service with added flexibility in how you submit your requests.
You can interact with the Tinify Webhook Proxy using either multipart form-data or JSON requests. Here are examples of both:
curl -X POST https://your-worker.your-subdomain.workers.dev \
-F "source=@/path/to/your/image.jpg" \
-F "apiKey=YOUR_API_KEY" \
-F 'resize={"method":"fit","width":300,"height":200}' \
-F 'preserve=["copyright","creation"]' \
-F "callbackUrl=https://your-callback-url.com/endpoint"
curl -X POST https://your-worker.your-subdomain.workers.dev \
-H "Content-Type: application/json" \
-H "Api-Key: YOUR_API_KEY" \
-H "Callback-Url: https://your-callback-url.com/endpoint" \
-d '{
"source": {
"url": "https://example.com/path/to/image.jpg"
},
"resize": {
"method": "fit",
"width": 300,
"height": 200
},
"preserve": ["copyright", "creation"]
}'
If a callback URL is provided, the worker will send the Tinify API response to that URL and return a success message. If no callback URL is provided, the worker will return the Tinify API response directly.