Something like Akamai does with some of their CDN products:
https://techdocs.akamai.com/property-mgr/docs/adaptive-img-comp-aic
It looks like they have some sort of logic on their edge servers to detect network type and also use the latency to determine if images should be compressed.