optimizing images

Hello, currently I store my images in R2 buckets but I also want to optimize/resize them. Can cloudflare images and R2 work together somehow? Does cloudflare images optimize all images from a domain or only the ones that are uploaded using its API?
4 Replies
Chaika
Chaika15mo ago
Cloudflare Images is a separate end to end solution, that takes care of storing/optimizing images itself. You upload images to it, specify what variants it should create, it handles storing them, and you access them via the url it gives you/a special cdn-cgi path. You could use something like Image Resizing (separate from Images) with R2
noctate
noctate15mo ago
@chaika.me that's interesting, can you give me some example how can I use image resizing with r2?
Chaika
Chaika15mo ago
If you have an image in a bucket, on a custom domain like https://i.chaika.me/e9ed1ae4adfe4c8d8ea938d1a3c7f67f You can access it via cdn-cgi/image for image resizing, if Image Resizing is enabled on your zone, ex: https://i.chaika.me/cdn-cgi/image/width=1800,quality=75,format=auto/e9ed1ae4adfe4c8d8ea938d1a3c7f67f (there's no extension for this file which makes it a bit weird to see, but it's just the same path as you would normally have, at the end. The full format is at https://developers.cloudflare.com/images/image-resizing/url-format/
URL format · Cloudflare Image Optimization docs
You can convert and resize images by requesting them via a specially-formatted URL. This way you do not need to write any code, only change HTML …
noctate
noctate15mo ago
thanks! @chaika.me
Want results from more Discord servers?
Add your server