Why JPEG compression is not the devil
Yes, the JPEG image format is compressed. Yes, information is lost in the process. But this is much less serious than some people think. Find out why here.
On my article "RAW vs. JPEG" a Mister Anonymous found:
One major disadvantage of JPEG should also be highlighted. The format uses a compression that is not lossless. Each opening and resaving changes the data and thus degrades the image.
He gained a lot of approval with this. I agree with this in theory, but I don't think this problem is important in practice. Let me explain why.
Compression is not evil per se
First a few words about compression in general. I keep realising that many people are terrified of anything that is compressed in any way. They believe, for example, that three quarters of the information is lost if a file only takes up a quarter of the space. That's wrong. Compression works more in such a way that the algorithm only communicates something when there is actually something to say.
Highly simplified example: We have an image block that consists of 3x3 pixels. All pixels are white. In an uncompressed file format such as BMP, this block is described as follows:
- The first pixel of the first line is white
- The second pixel of the first line is white
- The third pixel of the first line is white
- The first pixel of the second line is white
- The second pixel of the second line is white
- The third pixel of the second line is white
- The first pixel of the third line is white
- The second pixel of the third line is white
- The third pixel of the third line is white
The same can also be said in shorter form:
If each pixel has a different colour, this must of course also be listed in detail in the compressed format. But only then. That is the difference. Compression describes an image flexibly, depending on how much information is required. With uncompressed formats, each pixel is simply defined separately. It is similar in the audio sector: an uncompressed audio file always requires the same amount of space per minute, regardless of whether there is total silence or complex orchestral music. With MP3, on the other hand, the file sizes are different in both cases.
Compression becomes problematic if you compress very heavily. Then the compression algorithm starts to combine things that it should actually separate, in the style of "these nine pixels with different colours are all grey-brown on average".
Camera JPEGs are of high quality
The perceptible loss of quality during compression is not linear. It runs more like this:
This means that you can compress fairly painlessly up to about the circled area and thus save a lot of data volume. With very high compression, however, every additional kilobyte saved causes visible damage.
The JPEGs that come out of your camera are all in the high, practically invisible range. This also applies to the lower quality levels. No camera manufacturer is stupid enough to save crippled images and not even save much space in the process.
Resaving results in a loss of quality anyway
When editing an image, a lot of information is naturally lost, regardless of whether compression is used or not. For some processes, such as cropping an image, this is perfectly clear. But even when rotating a photo, for example to straighten the horizon, the image loses sharpness. This is because each pixel has to be shifted a little and then does not fit exactly into the rectangular grid that the image format prescribes for the image information. Only 90-degree rotations are loss-free because each pixel fits exactly into the space of the pixel grid.
I tried this out using an extreme example. The following image was rotated 18 times and saved again and again. The last time it was rotated, the image was aligned as it was originally, so the image has been rotated 360 degrees.
This is the original image. Our website automatically compresses the images after uploading. This means that the image is not quite original. But you can still see the difference very well.
After 18 rewrites with lossless tiff, all sharpness is gone:
18 times rewritten with compressed JPEG:
Admittedly, the JPEG looks even worse than the tiff on closer inspection (especially the colour gradations in the sky). But the tiff also looks really bad. So bad, in fact, that somehow the additional flaws in the JPEG no longer matter.
You don't usually have to save again
Of course, you will never re-save an image 18 times. Instead, you'll keep the original and start from scratch if you realise you've made a mistake with your editing.
This is exactly what most of today's image editing programmes do anyway. The original is kept in the background, and if you change your settings regarding brightness, contrast, etc., this is always recalculated from the original. From the simple photo app on the iPhone to Adobe Photoshop Lightroom, this is almost always how it works. This is called "non-destructive image processing".
Good old Photoshop is now 27 years old, which is noticeable in the basic concept of the software. However, there have also been various options for non-destructive editing for a long time. The most important of these are the adjustment layers.
If you select "New adjustment layer" from the "Layer" menu, you can save a specific setting, such as the exposure, as a layer. You can then change the sliders as often as you like without changing the original image. To do this, however, you must save the image as a Photoshop document (.psd) and then export a JPEG from it if you want to share the image on the internet.
Summary
- The JPEGs that come out of a camera hardly ever have visible quality defects. They are "carefully" compressed.
- Even uncompressed formats are not protected against loss of information when saved again.
- Repeated saving in a compressed format is usually unnecessary and unusual in today's image processing anyway.
This leads to the completely surprising realisation: JPEG is not a spawn of hell.
My interest in IT and writing landed me in tech journalism early on (2000). I want to know how we can use technology without being used. Outside of the office, I’m a keen musician who makes up for lacking talent with excessive enthusiasm.