The Internet loves a good format battle.
We might be about to get another one.
The three current formats are:
- JPEG is lossy compression, best for photographic or complex images. But the lossy part means it's awful for some kinds of image, especially simple text.
- GIF is lossless, and therefore good for text - but can only show 256 colours per image.
- PNG is a lossless format created to replace GIF, and is used a lot for simple logos and elements of design (borders, bullet points, arrows, etc). It can use more than 256 colours in an image.
If PNG was created to replace GIF, why do we see so many GIF files on the internet? Basically, GIF supports simple animation (video). PNG doesn't. This was a decision early in PNG's development, taken because GIF's animation was very crude and viewed as a mistake that they didn't want to repeat.
A modern video format uses keyframes - still images - and then describes the changes that happen in the following frames as things move or change shape. This is efficient. GIF simply stores every frame, in its entirety, as an image. This is very inefficient. At the time PNG was being created, everyone was of the opinion that if you wanted animation, you'd use a proper video format.
Nobody foresaw that GIF would gain a resurgence in video use a decade after it had been left for dead. And the main reason GIF had that resurgence was that GIF files are easy to build, and can be viewed on just about everything. If you've got a GIF file, you've got working video. By comparison, actual video is more complicated - especially in the tools used to build video.
So when smart geeks wanted to create short animations to express shock or amusement, they did it in GIF files because they knew they'd work. This became popular outside of the geek subcultures, and now we're seeing GIFs everywhere again.
PNG actually has not one, but two variants that can do animation - MNG and APNG. Neither ever caught on, but APNG has a little more support than MNG. (Not enough that you'd feel comfortable using them on a website though.)
Some more history
PNG wasn't created to replace GIF for no reason though - it was created because of a patent threat. GIF used a compression method that UNISYS had patented, and that meant that the early internet was under threat from huge licensing fees.
There was a big push to replace all the GIF files with PNG files around 1999ish, because UNISYS didn't stop at asking for money from browser creators - they magnanimously offered website owners a chance to license their patents for as low a figure as $5000. If you were a non-profit organisation, that is. For private individuals or small businesses, $7500 was the rate.
Funnily enough, the internet revolted and switched almost wholesale to PNG. It took a while, but we got there in the end.
It only became same to use GIF again in 2004, when the last of the UNISYS patents expired.
So, we're a fair old way into an article titled "BPG vs JPEG vs WebP vs JPEG-XR", and we've only briefly mentioned one of the titled formats. What the hell is going on?
Trust me, the recap of GIF/PNG was worthwhile. You'll see why.
But first, have a picture, to break up the text:
(That photo has nothing to do with this article. None of them will. Sorry.)
The problem with JPEG
JPEG is arguably the world's most used graphical format. It's what your digital camera uses, it's 99% of large images on the web, it's everywhere. Everything can read and write JPEG.
It's this popular because it's lossy - it saves space by throwing away parts of the image your eye will either not see, or will interpolate into place anyway.
It's also old. Really old. It dates back to the early 90's, and we've learned a lot about how to compress images since then. We can do better, and have been able to do better for at least a decade. In the early 2000's a format known as JPEG-2000 was floated as a replacement, but a combination of licensing and performance issues meant it never really stood a chance on the internet. The only browser to have ever seriously supported JPEG-2000 is Apple's Safari (although others have through plugins).
Despite being a workhorse, JPEG is ripe for replacement - especially when it comes to mobile internet. Images are well over 50% of the average web page, and if we can make those images smaller then we make the internet faster.
BPG (which stands for "Better Portable Graphics") was only proposed last week, and it's the reason for me writing this, as I spent quite some time looking at it and its competitors.
Remember how I described video working? A "key frame" and then just describing the changes? Well, BPG is basically a key frame from the HEVC next-generation video format (which will replace the current h.264 format that almost all videos you ever watch on the internet are currently using).
I really encourage you to check out the visual comparison of BPG versus other formats - in particular, compare it to mozjpeg and WebP. Mozjpeg is Mozilla's improved JPEG encoder, and WebP is one of the other competitors we'll be talking about.
Go ahead, check out the comparison - I'll wait.
I'll just throw a photo in here, to break up the text, whilst you're playing with those comparison images.
OK. You've seen the results, and BPG is better. For the same file size, it's much better than mozjpeg and a little better than WebP.
So, BPG is going to be the next format we use on the internet, right?
Well, in my opinion, probably not.
BPG's licensing woes
Remember why we have PNG? UNISYS and those patent license requirements? Well, BPG is based on HEVC, which has LOADS of patents involved. So many, that all the companies who have patent(s) which are applicable created a licensing group called MPEG-LA who collect them and distribute the money amongst its members. It's kind of like a cartel, except inexplicably legal.
MPEG-LA is not known for being kind or generous. It exists only to collect money for those patents that its members have provided, and like any good corporation it pursues that goal methodically. The difference between UNISYS and MPEG-LA is that occasionally MPEG-LA has known when to back down. Like the time they threatened to charge everyone on the internet who transferred a video (not play it - just download it or send it via email would be enough). They then changed their mind when it became clear that was less popular than a Nazi-themed kitten culling party with no cake.
The creator of BPG has proposed that we could bypass the patents by "asking the hardware to do it for us", on the assumption that all hardware in the future will be able to handle HEVC. This is nuts, because it relies on having drivers for the hardware. That might sound odd - surely you'll always have drivers for the hardware? But that's not the case. Consider the very popular Raspberry Pi - the manufacturer provided drivers for some OSes, but not others. Other OSes can run, but can't access the advanced graphical features of the hardware - like decoding video.
To not have full support for hardware can be fairly normal when it comes to the more embedded (read:cheap) end of the market - it's often not difficult to write a driver to do basic display work, but writing a driver to do the fancy stuff like decoding video or doing 3D graphics requires a lot more work and/or access to decent documentation. More work than most free software projects can take on.
Handing image decoding off the to the hardware will create an internet on which you can only see some images if you're running a supported system.
You might ask what's wrong with sticking to the manufacturer's supported system. Good question!
Well, they fall out of support fairly quickly. Which means that they don't get patches for bugs after a while. And on devices connected to the internet, that's very bad. Free software - Linux distributions, the various Android ROMs - are a great way of getting more life out of a device once the manufacturer has decided to stop supporting it, and can greatly extend the life of a device. We've seen this happen with laptops and netbooks, and it will no doubt happen in the future with tablets and perhaps phones. This should be encouraged, and BGP becomes a barrier to accomplishing this.
(You might not plan to put Linux on your tablet, but a charity sending it to those less fortunate may well want to. Your device's useful lifespan may not end with your ownership.)
Time for another picture:
Licensing aside, how likely is BPG to get widespread adoption?
Unless we get decent resolution to BPG's patent problems, I can't see Mozilla taking it up. Nor Google, as they have their own dog in this fight - WebP, which we'll come to shortly. Apple and Microsoft are part of MPEG-LA, but only Apple has announced it holds patents for HEVC - so in theory, only Apple profits from BPG becoming a widely used format. (Microsoft may also have patents for HEVC, and not have announced them - I don't know.)
So the only major browser likely to support BPG is Safari, with Internet Explorer a "maybe".
Microsoft has had a JPEG alternative for almost a decade now. They released JPEG-XR in 2006, and it's fairly good.
It produces smaller files than JPEG, and the only criticism I see levelled at it is the slightly slow encode/decode speed.
Traditionally, Microsoft have been a bit of an evil "Not Invented Here" empire. But with JPEG-XR there's a remarkably free license (BSD), and free tools to help developers get started in adding support to their programs.
And yet the only browser to support JPEG-XR is Microsoft's own Internet Explorer.
Microsoft initially courted camera manufacturers and consumer electronics manufacturers for support, but that also went nowhere.
I'm sort of at a loss with JPEG-XR. Microsoft did good with it, but then just kind of lost interest. Some tools are there, but not many - and they're not exactly all-a-flurry with ongoing development.
I just can't see Apple, Google or Mozilla supporting JPEG-XR at this point. It's far too late, and both WebP and BPG look more attractive.
JPEG-XR is just a giant missed opportunity, and might be a good case study of how a reputation can ruin a product before it's even launched...
Time for another picture break:
WebP was released in typical Google style - as a beta. As such, its initial early stages got it some poor reviews - but Google persisted, and it's now a pretty good format.
It gets close to the quality of BPG, which is impressive considering that the WebM format is a generation behind the technology used in BPG. Google also have a next-generation video format that they're working on, but WebP is four years old - so understandably uses the current generation. However, this does suggest that there is a fairly clear path for WebP's future.
But what's really impressive is WebP's support. Google may have thrown it out at first in 2010 as a fairly unfinished product, but I was surprised at how far it's come.
- Both the Chrome and Opera web browsers support WebP natively
- Android has supported WebP since version 4, so apps can use WebP files natively with no extra code
- The PageSpeed module has decent support for it
- Facebook have experimented with it, with mostly positive results
- CDN's have experimented with it, again with mostly positive results
OK, so having Chrome and Opera support it isn't impressive, as Opera uses Google's Blink engine - the same one as Chrome. The Android support isn't a huge surprise either - but it does cover 90%+ of all Android devices, so is very comprehensive.
I was very impressed with the Pagespeed module. It's an add-on for the Apache or nginx web servers - which covers about 90% of all active websites. It's designed to make pages load faster by silently optimising them in the background - and one of its tricks is to spot when a client supports WebP and use that instead of JPEG. Seamlessly. It's very neat. (It can also save space by recompressing JPEGs to use higher compression, by resizing them to match common screen sizes, and a few other tricks. Check it out, it's pretty neat!) Of course, Pagespeed is a Google project, so WebP support is to be expected - but they've made it easy and relatively foolproof, which is very nice. If Microsoft had supported JPEG-XR to this extent, it might have gone further.
The Facebook experiment shows that only users who tried to right-click on images and save them to a local disk noticed that they had WebP images - this is presented as a failure by the CNET article, but would have hit any of the formats discussed here, so I don't regard it as a showstopping problem.
The fact that CDN companies are actively looking at WebP is intriguing. A CDN - Content Delivery Network - is basically a big networking cache that companies put between them and their customers. If you're CNN, why rely on your own hosting? Stick a cache in front and let that cope with the load, and concentrate on producing content.
WebP isn't the most technically accomplished of the options here - it lacks colour space options, the maximum image size is lower than JPEG (16383 pixels wide as opposed to 65535 for JPEG), and so forth. But for a web browser, it's good enough. And the support and toolset is enviable, if limited to just Google's ecosystem at present.
Licensing? WebP is distributed under a BSD license, just like JPEG-XR. And the video format it was taken from has an irrevocable patent grant from Google, which means it has no patent issues that anyone knows of.
So will others support it? Well, for political reasons, I'd expect Apple to be the last to support it. They have more to gain in licensing terms (via MPEG-LA) with BPG. Microsoft is an odd one - they're being very open and friendly these days, and might just choose to make supporting WebP an expression of that to reassure people. Mozilla, I feel, are the key. They initially rejected it - but the bug for support kept getting re-created, and one of those bugs is where Facebook and the CDNs began revealing their experiments. Mozilla are now considering supporting WebP in the future, but have made no commitment.
One last picture...
Conclusion - Mozilla, the Kingmaker
Initially, after evaluating WebP, Mozilla decided that there was more mileage in creating mozjpeg - an improved JPEG encoder. But that only took people so far, as it only reduced JPEG sizes by around 5%. WebP can routinely get 30% savings.
If Mozilla supports WebP, I think that's the tipping point. I still have hope for Microsoft and no hope for Apple, but I believe that Mozilla are key. If they ship WebP support, then WebP will be the best choice for a JPEG replacement.
And if they don't?
I suspect we'll just stick with JPEG, to be honest. MPEG-LA might surprise us, but I'm not betting on it. JPEG-XR will continue to be unloved. WebP will grow in use in Google's ecosystem, but nowhere else. Apple might ship BPG support, but it'll get no support outside of Apple's ecosystem without explicit patent promises. Even if it does get support, many will probably shun it at first due to the patent issues.
Sticking with JPEG isn't that bad, after all.
(Well, unless you're Facebook or Google and could cut your bandwidth bill by 30% overnight...)