The original file that was uploaded to Cloudflare Images that is. I’d like to cut out the middle man (Backblaze B2) and upload images straight to Cloudflare images and have the option to serve thumbnails, optimized, and original files (when users request it). Is this possible?
I just did a limited test on one image only. I’d already had flexible variants enabled but hadn’t had a chance to test much with it yet though. Using the URL format below, it served-up the original size image that I’d uploaded.
I’d tested this with gamma=0 being the only option because it required me to include at least one option. Otherwise, it said the URL was malformed. The documentation says that a 0 value for gamma is ignored. That’s why I’d included it as a dummy option of sorts, just to test.
Interestingly, when I downloaded it, I checked its file size and it was bigger than the original I’d uploaded. However, the dimensions were the same as that of the original I’d uploaded though.
Flexible variants is a way to do this, as @jwds1978 mentioned.
Another way is to create a variant with the height/width set absurdly high such as
99999 - we have a ‘public` variant like this, so we can serve the original image when needed. It won’t be resized to larger than it currently is, so this trick works well.
The file that gets returned is still transcoded to an optimized format right? I’m looking to return the original file as-is, usually for the user who uploaded it.
I’d tested what @cherryjimbo had mentioned about a ridiculously large variant. I made a new variant with a height and width of 999999999999999px.
When I downloaded that image from its image URL, as with the flexible variant I’d tested earlier, the file size was larger than the original I’d uploaded. Both ways served-up the dimensions of the original image, but both had a larger file size of ~3.07MB compared to the original of ~2.25MB though. I’d tested with a transparent PNG that’s, originally, 3640×4096.
@jwds1978 I tried on my end with a ~8MB transparent PNG original, and ended up with a transparent PNG that is slightly lighter when served via Cloudflare. Any chance you could share the image where you saw such an increase in filesize?
If you can access my Images account, go ahead. It’s the only image I currently have stored in Images — Image ID 715415d9-2604-4790-11ab-6e9722019200. If you prefer, I can also provide the original image here.
I’ve just created a ZIP archive for you and you can download it here. Within it, you’ll find the original image that was uploaded to my Images account and the image that was downloaded from its public variant.
This topic was automatically closed after 15 days. New replies are no longer allowed.