John Resig
John Resig
CDCloudflare Developers
Created by John Resig on 2/20/2025 in #workflows-beta
Gotcha - ok, thank you! I'll do some
It worked!! You're a lifesaver. I'm using the 2025-02-14 version of the runtime with wrangler v3.109.2. I added the binding to my wrangler.jsonc and confirmed that the JSON Schema allowed this new binding. Unfortunately, I noticed that the type generation didn't add the new binding so I had to manually update worker-configuration.d.ts to add: IMAGES: ImagesBinding; and then in my code I ran:
const image = await fetch(imageUrl);

if (!image.body) {
throw new Error(`No image body: ${imageUrl}`);
}

const output = await env.IMAGES.input(image.body).output({
format: "image/webp",
});

await env.R2.put(filePath, output.image());
const image = await fetch(imageUrl);

if (!image.body) {
throw new Error(`No image body: ${imageUrl}`);
}

const output = await env.IMAGES.input(image.body).output({
format: "image/webp",
});

await env.R2.put(filePath, output.image());
And it worked! I also tested out doing a transform with .transform() and that worked, as well. I've got it running in production now! So I think that once the type generation is working it'll be totally fine (I can just keep it manually updated for now). Thanks again!
2 replies
CDCloudflare Developers
Created by John Resig on 2/20/2025 in #workers-help
Image transforms via Worker/Workflow not working
Got an answer over here. Turns out Workflows are run in the workers.dev zone, which means that they don't have access to the Images product, as that's limited to specific zones.
3 replies
CDCloudflare Developers
Created by John Resig on 2/20/2025 in #workers-help
Image transforms via Worker/Workflow not working
3 replies