Transfrom image via worker


I use worker to manage my R2, I would like to know how to transform image. Based on the documentation it is possible :

But the documentation is not very clear because it use “fetch” with the key “cf” :

cf: {image: {anim: false}}

Can I use this object with the R2 binding in a wrangler, like this :

env.BUCKET.get(key, { cf: { image: { blur: 50 } } });

env.BUCKET is binded to the bucket connected in wrangler.toml for interacting with it, check the documentation :

Nope, you can’t.

Your options for workarounds are:

  1. Have a separate Worker to fetch the object from R2 and then fetch it from a different zone with image params.
  2. If suitable for your security posture, make the bucket public with a Custom Domain and then fetch that domain with the image params. Public buckets · Cloudflare R2 docs
  3. Use the S3-compatible API instead, and combine a library like aws4fetch with the image params.