R2 and image transformations download

I have a bunch of images stored in an R2 bucket, and I use them through my django app with django-storages (works flawlessly). On the website, there is a download button for an image like this: <a href="<link to r2 image>" download="<filename>"/>.

This works fine, however I would like to offer download of the file in different formats, and I already use image transformations, but when I change <link to r2 image> to be /cdn-cgi/image/quality=100,format=webp/<link to r2 image> for example it only ever downloads the original file in the original format its stored in r2. Any ideas how I can achieve downloading the transformed file?

You can use worker to do format negotiation yourself, but note format options works as a format hint and there is no guarantee an output image will be of your requested format Transform images · Cloudflare Image Optimization docs

1 Like

Thank you, I decided to just do it from my own server. I created a download url that got the image via python requests, then just streamed it back to the frontend with Content-Disposition set to attachment and its working flawlessly.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.