However, as TFA mentions, better compression is currently a double-edged sword, because the CPU has become a bottleneck again: even top-of-the-line Android phones have weak Qualcomm CPUs, and sites use so much JavaScript that even high-end machines can struggle.
So we may end up living with JPEG for a few more years. This format has been designed when CPUs had 25Mhz, and we've had over 25 years to optimize the implementations, so we get a lot of bang for the buck from it.
Most of which has nothing to do with compression format, to be honest. No image compression format is going to save us from websites that use 2000x2000 sized photos for 200x200 author thumbnails.
Maybe I should write one, I guess.
https://github.com/metalabdesign/sharp-loader
https://github.com/herrstucki/responsive-loader
https://github.com/tcoopman/image-webpack-loader
(and many more, just grabbing a few examples)
Something that I've not seen is a plugin/loader that will automatically use the <picture> tag to make available multiple auto-generated source images and a fallback <img>. It'd be great to be able to
import myImage from 'res/img/my_img.png'
and have myImage be a string like
<picture><source srcset="[generated-name-of-my-image.webp]"><img src="generated-name-of-my-image.png"]></picture>
Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith.
This sounded like an obvious truth but I think you're wrong!
JPEG has progressive rendering, so a browser could easily decide to stop once it has rendered enough for the image size. Once you zoom or if it's used elsewhere, it can render a little more.
I just checked the Google homepage, and even the New Year's Eve Google Doodle currently being shown is a good ol' GIF, rather than a modern format such as WebP. And this is with me using a desktop Chrome browser that definitively supports WebP.
> Like many things, the costs of switching image formats are definite, but the benefits are questionable.
One easy way to get some of the benefits without incurring the switching costs is to leverage Cloudflare Polish[1]. I've used it at a few places, and have had good experiences. Although the majority of gains came from optimizing images that were poorly optimized to begin with, rather than the incremental improvements that occurred from enabling WebP support.
[1] https://support.cloudflare.com/hc/en-us/articles/36000060737...
new-years-eve-2018-4995722058399744.2-law.gif
299 972 bytes
new-years-eve-2018-4995722058399744.2-law.webp
293 636 bytes
new-years-eve-2018-4995722058399744.2-law.apng
251 516 bytes
Interesting...
On some old and buggy machines, that might cause the browser to crash too.
Not something Google wants to risk for a doodle - that's why all non-trivial doodles require a click to load.
OTOH it might be cheaper (relatively) on phones as they can offload the work to hardware components and ramp CPU down (or avoid ramping it up).
with the resulting out.webp being 285 932 bytes, so it seems apng does a very good job here, unless I'm using suboptimal options for webp.
HEIF is made by MPEG. HEIG is extensible (see AVIF fusing the AV1 royalty-free codec). Also an application format (MIAF) will ensure interoperability.
While waiting for native browser support, some js implementation would do the job.
What else?
Formats do not provide HW acceleration, implementations do. And so far there is zero HW accelerated HEIF implementations for the web.
You sure of that? Apple[1] and Qualcomm[2] might argue otherwise.
[1] https://developer.apple.com/videos/play/wwdc2017/513/
[2] https://techreport.com/news/34306/qualcomm-snapdragon-855-sp...
https://chrome.google.com/webstore/detail/h264ify/aleakchihd...
$ convert 400px-President_Barack_Obama.jpg.av1.mkv.png -colorspace YUV -channel 0 -separate Y.png
$ convert 400px-President_Barack_Obama.jpg.av1.mkv.png -colorspace YUV -channel 1 -separate U.png
$ convert 400px-President_Barack_Obama.jpg.av1.mkv.png -colorspace YUV -channel 2 -separate V.png
$ convert U.png -filter point -resize 50% -filter Mitchell -resize 200% smoothed_U.png
$ convert V.png -filter point -resize 50% -filter Mitchell -resize 200% smoothed_V.png
$ convert Y.png smoothed_U.png smoothed_V.png -combine -set colorspace YUV -colorspace sRGB combined.png
Result: https://imgur.com/a/AwoVmh1There's a big thing that bugs me about that when it comes to the web: Software patents and licenses basically ruined wavelet-based image compression schemes on the web.
Wavelets would have been ideal. Basically, the lossy compression would work about the same as the cosine transform in JPEG, but by using the discrete wavelet transform, you basically get thumbnailing built in: Imagine transmitting a tiny little thumbnail of your image. Then, you transmit the information used to derive a version 4x that size (2x width, 2x height) from that. Then, you transmit the data used to derive the next 4x layer. Rinse, repeat -- that's exactly how image data is organized after a wavelet transform.
With some clever adaptions, this could have done away with so much cruft and complexity we have today (like image sets and @media queries for background images): Imagine just putting a 4K version of your background on the server and telling the browser how to render it (an <img> tag with a specified size, or background-size in css). The browser could then start loading the image until it realizes it has all the data for your resolution (say on your phone), and just terminate the transmission before the whole image is downloaded.
Except for JPEG2000, which Safari supports but does not include in its Accepts: header. So Akamai just sniffs the user-agent and serves JPEG2000 to anything that looks like Safari, whether they support it or not.
Edit: I agree that something like the pagespeed module rewriting html probably goes too far and html rewriting is fraught with weird edge cases, but content negotiation is something only a webserver (or CDN) can do.
Jpeg was released the MPEG-1 ( H.261 ) era. Since then we have had H.262 / MPEG2, H.263 / Divx, H.264 /AVC, H.265 / HEVC, and the coming H.266 / VVC. If we consider the amount of improvement we got from Video Encoding, images hasn't changed much at all, we happen to fine tune the heck out of Jpeg. And I hardly call a new image format with 50% reduction bitrate compared to a nearly 30 years old tech a major breakthrough, and that is without mentioning the huge decoding resources requirement.
There are many project that just improves on JPEG, Dropbox had a lossless compressor for JPEG, and Cant remember if Pik was originally based on jpeg as well.
Unless there is a real major breakthrough that gives the current best JPG encoder quality at 25% or less its size, focusing on 200KB, 100KB, 50KB images size, ( i.e the new image will have to be 50KB, 25KB, 12.5KB ) while using within 2x decoding power. I am convinced our roadmap for Network bandwidth improvement in the next 3 - 5 years are going to make JPEG to last forever.
New formats are not supported on all browsers so you wind up having to support the mainstream formats as well as one or more new formats. Rather than benefiting from reduced storage costs, your storage costs get multiplied.
Performance is also a problem, particularly when people add "yet another polyfill" to get an image to work without native support.
Once I get into eyeballing images closely I also end up questioning if the compression gains are real. For instance, one I read a comment on the article here
https://calendar.perfplanet.com/2018/is-avif-the-future-of-i...
and looked closely I couldn't unsee that the AV1 had very different artifacts than the other compressed images. Not necessarily worse, but definitely different. Unlike the poster I liked the way the suit rendered but definitely there was a lot of blocking around edges that the poster interprets as "pixelation on the flag".
Like many things, the costs of switching image formats are definite, but the benefits are questionable.