Gotcha - ok, thank you! I'll do some

Gotcha - ok, thank you! I'll do some experimentation later today to see if I can get it to work with another worker w/ service bindings - and if not, probably another worker doing a normal fetch().
2 Replies
Unsmart
Unsmart•2d ago
Look like they actually are releasing something to make it so you can use transforms regardless of the zone the worker is running in: https://github.com/cloudflare/cloudflare-docs/pull/20141 It supposedly is live already so lmk if it works for you 👀
GitHub
[Images] Images Bindings by dcpena · Pull Request #20141 · cloudfla...
Added docs for Images Bindings to Images and Workers docs.
John Resig
John ResigOP•20h ago
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!

Did you find this page helpful?