Is it possible to set image quality when
Is it possible to set image quality when using Cloudflare Images? I see that you can when it's coming from a server and going through Cloudflare, but doesn't seem to work when the images are hosted by Cloudflare. This is a major blocker that's slowing down my site because everything is being served at original quality.
16 Replies
With Flexible Variants, you can set a Quality parameter:
https://developers.cloudflare.com/images/manage-images/enable-flexible-variants/
Cloudflare Docs
Enable flexible variants | Cloudflare Image Optimization docs
Flexible variants allow you to create variants with dynamic resizing which can provide more options than regular variants allow. This option is not enabled by default.
@sdayman That's what I'm using. I can set all kinds of parameters with it except for quality
As an example, see this image: https://imagedelivery.net/MRTPzGIpYfy00UVryjholQ/718d3515-4d46-42f5-fff8-09f17f9cef00/w=512
I can't put
quality
or q
on it (an attempt at 10%): https://imagedelivery.net/MRTPzGIpYfy00UVryjholQ/718d3515-4d46-42f5-fff8-09f17f9cef00/w=512,quality=10I also can't change the format: https://imagedelivery.net/MRTPzGIpYfy00UVryjholQ/718d3515-4d46-42f5-fff8-09f17f9cef00/w=512,format=jpeg,quality=10
As a sanity check, here it is with
sharpen
: https://imagedelivery.net/MRTPzGIpYfy00UVryjholQ/718d3515-4d46-42f5-fff8-09f17f9cef00/w=512,sharpen=10Darn, you're right. Docs say Quality only applies to Transformations, so not for Flexible Variants:
https://developers.cloudflare.com/images/transform-images/transform-via-url/#quality
Same with Format
Is there a workaround or anything? Can I send Cloudflare Images through Transformations?
Possibly, if you allow Transformations from any origin.
I'll give it a shot
Thanks for the help! In the meantime, any info on when Cloudflare will be adding those params to Flexible Variants?
It didn't like that
https://ana.so/cdn-cgi/image/sharpen=2/https://imagedelivery.net/MRTPzGIpYfy00UVryjholQ/718d3515-4d46-42f5-fff8-09f17f9cef00/w=512
It seems to be specifically disallowing imagedelivery.net
This is the hackyest hack I've ever seen
@sdayman Do you think this is something that I can rely on until Flexible Variants gets official support for
quality
? I don't want to start using this just to have the rug pulled out from under me.I don't see why that would stop working. You've allowed it to pull from any origin, and that's what it's doing.
I've actuallly disabled it from pulling from any origin
Technically, it's still getting it from the same origin
If you look at the url, it's just pointing the
/cdn-cgi/image/quality=2/
to /cdn-cgi/imagedelivery/
, but that seems like a recursive call that might become patched at some point, even if accidentalOh, right. You're using the custom domain URL. I wouldn't call that recursive. It's more like a request and a subrequest.
Okay fair enough
If it works it works