Image d'illustration, Aimevhé Photograpies : photo animalière, paysage, nature, concert

50 Shades of Grey (A Short Guide to Image Formats)

Le

Catégorie :

Ecrit par :

Historically, we’ve had three common image formats, released in the late 1980s and early 1990s, that are still used for our pictures and photographs today.

The veteran is TIFF, released in 1986. It’s the go-to format for printing. The files are very big and take up a huge amount of space, but the quality is there. It handles trillions of colours, which is essential for flawless image quality.

It’s on these two criteria, file size/compression and the number of colours supported, that the different file formats compete.

File size

In 1986, internet connections were painfully slow. Displaying a website with TIFF images was out of the question. That’s why CompuServe developed the GIF format. By limiting the number of colours to 256, it produces very small files that can travel over low-bandwidth networks. GIF was used for a very long time, especially for logos and icons, where 256 colours were enough. Today GIF has been overtaken even for logos, which now use SVG, a vector format that’s excellent for colours, file size and resizing, but completely unsuitable for photos.

GIF is now only used for short animations, the one area where it still has an edge.

So the first way to shrink files was to limit the range of colours they could handle.

The human eye

Our eyes can see around 10 million colours. If you want faithful rendering, you need an image format with more than 10 million shades. In fact, you need far more than 10 million to handle subtle gradients properly (16 million at the very least).

GIF degrades image quality too much, which is how JPEG arrived in 1992, followed by PNG in 1996. Both handle 16 million colours.

As you’ll have guessed, that makes files bigger, when the whole point is to keep them small. So compression algorithms are used to keep the file size in bytes under control.

Compression

JPEG compression is lossy, unlike systems such as “zip”. When you zip a file and then unzip it, you haven’t lost any data, but that approach isn’t very effective on photos. Something else had to be invented.

The first trick is to bank on the limits of the human eye by reducing colour precision. That’s where information starts to be lost.

With images, you approximate. When two neighbouring pixels have similar colours, instead of storing two colours you store their average. More precisely, you take blocks of pixels and store a summary of each block. If you push compression too far, you start to see big squares in the picture: that’s why.

The information is gone. That’s not a problem in itself, as long as you can’t see the difference.

The 256-shade problem

With these file formats (JPEG, PNG), each colour channel only has 256 levels. Take grey: it goes from white, through the greys, to black in just 256 steps. The whites get pushed to the extreme, light tones turn very white, and the greys quickly turn very dark. The same happens with the other colours that make up an image on screen: red, green and blue.

As a photographer, you sometimes want exactly that subtlety in the greys. That was my case with landscape photos featuring the northern lights: I wrote that blog post with the photos in JPEG. The photos are fine, but I wanted to work on the shades of grey in the landscapes, and unfortunately JPEG can’t deliver them. It was a chance for me to test the compression of the other, more modern formats offered by Lightroom.

The new AVIF and JPEG XL formats: results on my northern lights photos

These formats are recent, from 2019 and 2021. They offer exceptional compression and a much wider range of colours. Exactly what we need for photographs. In the blacks, for my northern lights pictures, AVIF produces photos with the quality of an uncompressed JPEG, but at a much smaller size. As you’ll have guessed, I still lose my shades of grey. So it isn’t a solution in this case.

The solution is JPEG XL, which I believe will be the standard photo format in the years to come. Web browsers now support it (except Firefox, where support was still being implemented when this article was written).

Except that…

Even though it only dates from 2021, Google killed JPEG XL. While everyone was waiting for it to be switched on by default, Google announced in October 2022 that it was removing the JPEG XL code from Chromium (the foundation of Chrome) altogether.

The reasons Google gave ruffled a lot of feathers:

  • Reducing the code maintenance burden.
  • Lack of interest from the ecosystem.
  • Not enough performance gain over existing formats (such as WebP or AVIF).

The announcement caused an outcry. Engineers from Intel, VESA, Cloudinary, Facebook and even Apple voiced their displeasure. They argued that JXL is technically superior to AVIF (Google’s favourite format at the time), because it handles very high-resolution images better and doesn’t need outlandish processing power.

Things changed when Apple announced default support for JPEG XL in iOS and macOS. Google revised its position and brought JPEG XL into Chrome. Only Firefox is left, and its support is on the way.

Why didn’t I publish my northern lights photos in JPEG XL?

In the end, JPEG XL adoption is fairly recent. Most website management tools are written in PHP and rely on an external library (GD or Imagick) to handle image files, and unfortunately these still don’t support JPEG XL natively.

So it’s still a little early to use JPEG XL on a website, but it’s only a matter of months.

Going further: HDR formats and screens

Useless for printing, HDR can also improve how blacks are handled on screen. But it needs dedicated displays, which are much more expensive, and not everyone has one. In the future our photos may gain depth thanks to HDR, but that will be a topic for another post on this blog.

Commentaires

Leave a Reply

Your email address will not be published. Required fields are marked *

Derniers articles

Catégories