How to get images from R2 to CF images
Hey, I want to upload large images to R2 (average Image size ~20MB). How can I copy these images to CF images for delivery? Workers won't be able to handle this.
5 Replies
What exactly are you trying to do? CF Images has a hard limit of 10 MB.
You can serve images from your bucket with an R2 Custom Domain. If you need to resize them, I would use Image Transformations, which can work off images in your bucket and has a max size of 70 MB
https://developers.cloudflare.com/images/transform-images/
Cloudflare Docs
Transform images · Cloudflare Image Optimization docs
Transformations let you optimize and manipulate images stored outside of the Cloudflare Images product. Transformed images are served from one of your …
In my case R2 is only a temporary storage and eventually will delete images from R2 and keep the original images on AWS deep archive.
I'm using R2 as my first distention because of the low egress, these images will need to be transferred to multiple destinations.
I understand that CF images have a hard limit if 10mb that's why I'm asking if there is any way I can resize these images to be under 10mb so I can move them to CF images.
Why use CF Images at all?
You can achieve the same general effect of CF Images by using Image Resizing on top of R2, for example, this is an image resized by Image Resizing in an R2 Bucket:
https://i.chaika.me/cdn-cgi/image/width=1800,quality=75,format=auto/e9ed1ae4adfe4c8d8ea938d1a3c7f67f
You can use CF Image Resizing in Workers as well to prevent them from changing options and such, but you would also be paying for Workers on each Invocation
CF Image Resizing only bills you once for each unique transformation in a 30 day period
https://developers.cloudflare.com/images/pricing/
Then you could just keep the source in the bucket.
To answer your original question, I'm not aware of any way to resize them so that they would always be under 10 MB, at least not easily with Image Resizing
Cloudflare Docs
Pricing · Cloudflare Image Optimization docs
Cloudflare Images lets you store, optimize, and deliver images from one unified API.
I'm trynna delete the images from R2 because of the storage cost, I'll be storing a large number of images every month, so I wanna keep a version of the images on CF images for delivery and keep the original copy on AWS archive (1tb is ~$1). So images should be on R2 for 1 month then deleted from R2, in this case I need an easy and cheap way to deliver these images to clients.
Hey @Chaika Could you give me a quick rundown on how you did this? I wanna use image resizing on R2 but since it merged with Images I don't know how to