Worker is not resizing

Hello, I have created worker, by copy pasting the example bellow https://developers.cloudflare.com/images/image-resizing/resize-with-workers/#an-example-worker However I have noticed on requests it keeps the quality to 100, how can I debug or validate cf options are correctly passed
Resize with Cloudflare Workers · Cloudflare Image Optimization docs
Using Image Resizing with Workers gives you powerful programmatic control over every image request.
2 Replies
ned4770
ned4770OP11mo ago
I have tried simplified version, by forcing the quality, but still no success:
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
let url = new URL(request.url)

let options = { cf: { image: {quality: 40} } }

const imageURL = url.searchParams.get("image")
if (!imageURL) return new Response('Missing "image" value', { status: 400 })
const imageRequest = new Request(imageURL, {
headers: request.headers
})

return await fetch(imageURL, options);
}
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
let url = new URL(request.url)

let options = { cf: { image: {quality: 40} } }

const imageURL = url.searchParams.get("image")
if (!imageURL) return new Response('Missing "image" value', { status: 400 })
const imageRequest = new Request(imageURL, {
headers: request.headers
})

return await fetch(imageURL, options);
}
Erisa
Erisa11mo ago
Make sure the worker is running on a zone that has image transformations available
Want results from more Discord servers?
Add your server