Elia Locardi is Back

About JPEG Images and Their Quality Degradation

About JPEG Images and Their Quality Degradation

You lose information when an image is saved in JPEG format. This is acceptable, unless you save the same image more than once. Let’s have a look at how much information you really lose.

The JPEG file format is widely used because of its small file size. You can use it on the internet, social media, and for print shops and albums. The file size can be so small because of its smart algorithms that can compress the file by throwing away the less important image data. Although there are smarter and better ways in doing this, for now the JPEG is still the standard.

Not every camera has the option to shoot in raw file format, like this Sony DSC-HV400v superzoom compact camera. Especially for photographers who use these kind of cameras, this article could be good to read.

First of all, I think the wisest thing to do is using the raw image data of the camera, and post processing your images yourself. If your camera can shoot in raw format, that is. The raw format allows you to use the maximum amount of information generated by the sensor. You can correct colors, exposure, and contrast without the penalty of image degradation. Up to a certain amount, of course. But you can also directly save your photo in JPEG format 

The software inside cameras can be used to give the in-camera JPEG a certain look. But this is very limited and it is less easy due to a number of different reasons. By saving the image as a JPEG in your camera, even in the best quality, you will throw away information. Not only the extra sensor information, but also due to image compression.

If you use in-camera JPEG images just the way it came off the memory card, and you don’t change anything anymore, then it is okay to do so. With most cameras the image is quality wise more than acceptable, as long as you save in the highest JPEG size available. But be careful with that file. Whenever you change anything in that JPEG, you will throw away information again when saving it a second time. And again a third time, and a fourth time. And so on.

Saving an image in JPEG format. I always choose the highest quality, although that might be unnecessary. Nevertheless, I used this setting for my experiment.

I became curious on how soon that information loss will be visible. We all read about it, we all know it happens, but a lot of photographers don’t realize what the effects are when you save a JPEG multiple times. That is why I took the time to generate a 1280 pixel JPEG image from a raw file, in the best possible quality, and save it over and over again. I wanted to see how often this could be done without losing the image.

I decided to open the original JPEG file in Photoshop 2020 and save it as a new second image. I opened that second image, to save it a third time as a new image. Next, I opened the third image and saved it again as a fourth new image. And so on, until I saved it 99 times. With each new file, the software compressed the image, reducing the image quality. This is what I saw happening

This is the JPEG file, generated from the RAW file, in Lightroom. This is the starting point.

After ten times saved, the quality of the file is reduced so much, you can see the artifacts appear. I already find this an unacceptable, unusable quality.

Just to see what will happen when the image is saved over and over again. After twenty times, the quality is very poor. This image can never be used, not even on social media like Facebook.

The image degradation continues and this is the result after thirty times saved. Nobody want their images to look like this.

This is how an image will look after you save it fifty times. Nobody will be saving their image that many times, but is good to see how terrible a JPEG will turn out if you save it over and over again.

After seventy times, this will be the result.

After ninety nine times saved, the image looks like this. It clearly shows how the quality will degrade.

When the image was saved a tenth time, I found it already unusable. I could have stopped there, but I wanted to see the result after 99 times. It was shocking to see the amount quality loss after only a few times. 

For this experiment I did not do any post processing. I just opened the file and saved it as a new file. I did the same experiment with an invert filter, every time I opened and saved the file, and the end result was the same.

This is the difference between the original JPEG from the raw file, and the file that has been saved for ninety nine times. It doesn't matter if you perform any post-processing or not, the result will be the same. Unless you post-processing will degrade the image even more of course.

A close inspection revealed to me, that the JPEG image has already significant quality loss after you save it six times, and to be honest, if you look real close to the five times saved image, there is already some quality loss visible.

Although I knew this would happen, I am surprised how much you lose after only six times. In a way it changed my thoughts about the JPEG file format.

This is the result after six times saved. I think this is the point where image degradation will become too obvious. This image has become unusable for high quality prints. The breaking point will also be depending on the complexity of the image, I presume.

I know there are photographers who insist on shooting in JPEG image format. And although I would not advise doing so, I can understand why. Perhaps they don’t know how to handle a raw file, or perhaps they are convinced this is the only honest way of photography. Or perhaps their camera has unique film simulations that produce amazing results, even in JPEG. There are also the photographers that don't have a camera that can save a raw image.

No matter what reason, I only can advise those JPEG shooters to be careful with their JPEG files, and never save that file a second time in JPEG format. Because every time you do, you will lose quality. If you insist on using JPEG, just make sure you keep the original JPEG on your computer and use it as the starting point of every correction you might do on that file. Always save the changed file as a new file, never overwrite the original. This way you will treat the original JPEG as a digital negative, from which you can work as a starting point.

Ninety nine files, each saved from the previous one, with a simple postprocessing performed that will not degrade the image even more. If you want to change your JPEG file, make sure you keep the original one original. Don't overwrite that file with the new version. Ever.

A few things might be interesting to know also:

  • Although you might not want to change anything to a JPEG, you might want to have a smaller version, or perhaps you want to level a horizon, or crop it, or you might opened it and save it by mistake. Saving it again might occur more often than you think.
  • Copying the JPEG file won’t affect the quality, only opening it and saving it again will do that.
  • Opening the JPEG and by saving it as a lossless TIFF or DNG file, you will prevent further degradation when working on the file.
  • When saving a JPEG as a TIFF of DNG file, you are better off shooting a raw file format in the first place.

I just want to point out, you have to be careful when you are shooting in JPEG. Keep the original file untouched. If you do, you will be alright.

Did you realize how soon image degradation will occur when saving a JPEG file again and again? And if you shoot JPEG, would you consider using raw files in the future, or will you continue shooting in JPEG and protect your files from saving it a second time? I would love to read about it in the comments below.

If you're passionate about taking your photography to the next level but aren't sure where to dive in, check out the Well-Rounded Photographer tutorial where you can learn eight different genres of photography in one place. If you purchase it now, or any of our other tutorials, you can save a 15% by using "ARTICLE" at checkout. 

Nando Harmsen's picture

Nando Harmsen is a Dutch photographer that is specialized in wedding and landscape photography. With his roots in the analog photo age he gained an extensive knowledge about photography techniques and equipment, and shares this through his personal blog and many workshops.

Log in or register to post comments

Jpeg is not the best file possible is known but this is not the correct way to do this thing... 'cause it's obvious that if you start with a jpeg saving everytime in a different image you lower the size 'cause you compress the precedent one ( especialy if you change the quality even only by 1 point )... but nothing happens if you work on the same image... I think none of us will worlk on copies saved 99 times...

That depends on the workflow : Someone who, for all his picture, make one change, save and close, that can go fast : Straight horizon, crop, light and contrast, colors, filters... that's already 5 changes on each picture. No need to reach 99 changes to see quality loss.

As I said, there are people who will open, change and save it again. Not as a new copy, but the same file. If they open it again, because it has to be changed a little bit more, it already be a third save.
You would be surprised how easy it is to save a file over and over again.

I have made very good money in the past fixing files that had been saved over and over many times and converted a few times to various profiles. It's tedious to get something "usable" but I wasn't cheap either.

JPEG came out in 1992. Windows 3.1 also came out in 1992.

Anyone still using Windows 3.1?

I understand you don't use JPEG anymore. In that case, in what format are you sharing your work?

My comment is meant to reflect the dated-ness of jpeg. JPEG XL or HEIF for a better format, however UNTIL they become popular enough for websites to accept them as an option, were stuck in the '90's.

I send .tiff for sharing photos.

tiff for sharing photos? That wouldn't be my first choice. ;)
HEIF is new, and probably becoming more popular the next year, I think. All the other won't be accepted. A lot of other formats have been proposed, but none have been able to make it

The amount of jpeg is severely lacking here... let's fix that.

I puked
What's this ? A bot that kills pictures ?

I've saved JPEGs a ton over and over and never had the degradation shown here. I may have better software -- not sure how to explain it.

In that case you should teach us how to do this.

What is your formula for weighing pixels?
I need to find out how many actual images I can get in 5 pounds.

First, if you save over and over without re-opening the image, you don't suffer from the problem because your software keeps the uncompressed representation. Second, if the software you use is not photoshop, the behavior may be different since the problem here is not just JPEG but the combination of JPG plus Photoshop. JPEG on its own would not behave as badly, but photoshop tries to be smart when opening JPG files, which unfortunately ends up creating lots of problems if you do it too many times.

It mimics the use of a JPEG file over time, of course. About PS, you always use the software of your choice and the possibility it offers, not about the way it behaves with JPEG images. I do believe other software will provide different results, but the degradation will occur in some way or another each time you open and save the image.

I don't have your patience but I bet it wouldn't occur half as much in a simpler software like gimp. Of course assuming you don't edit the image between save/open. The overall point remains true: JPG is not a good format for editing and quality loss accumulates. It's probably the best archival storage format though because it is the most widely supported and you'll most likely be able to open a JPG file fifty years from now. HEIF? Not so sure.

I've never known anyone who edits a jpg and then saves it as a jpg and then reedits the updated jpg. You edit losslessly, like in Lightroom, or you make layers in PS and save as a PSD or TIF for further editing.

JPG is old and outdated but its efficient and you can still do a lot of editing to the files.

Today, I think most people understand how to use a jpg, but during the first decade of this century, if you knew the catalogue and inserts industry, you would see a lot of that happen. Say you are a distributor and you need an image to represent the product your company sells or will sell soon. What they would do is call the manufacturer and hope to get an image of the product. Sales reps did not always get the best copy to pass on. Either the art department did not understand the request, they did not manage the images properly or the person before them didn't care at all. A lot of art people had poor understanding on how to manage digital images back then. I have seen many times pixels visibly breaking apart in clusters just like in the third image above where the author saves over and over. That and resizing images happened a lot in the past. Who did this?, no clue, I don't know anyone who would either, but it was common to see years ago. Sometimes, images would include a weird partial path that visibly had been used for alterations and showed traces of how much alteration had been done on the image.

You don't know everyone, Tony ;)
There are people who edit JPEG images. There are people who have cameras that don't shoot raw.

Lol I do, I used to load my canon 6d jpg in lightroom, edit it there, export multiple copies/versions to jpg. Then I would review these versions on irfanview or any viewer so I could quickly compare images back and forth (lightroom lags too much). Then I might load some jpg in Luminar AI to see what Luminae could improve further. I still do the same but I shoot raw and use canon dpp in addition, all of this takes a lot of time so I will have to learn to make this more efficient but Im so "perfectionniste", it's hard lol.

Someone above smokes too much dope and talks too much.

Possible flow:
Shoot Jpeg -> edits Jpeg -> uploads to social media -> someone downloads it -> reupload to whatsapp -> geta downloaded.

That is already 5 conversions with HEAVY resolution downscaling using the fastest, not the best, algorithm.

Whatever is the resulting image cannot be printed to a credit card sized image.

That is perfect. In that case the borrowed image can be obtained in high res quality by buying in from me ;)

But unfortunately your work as a photographer may be judged by this image being shown on a heavily satured smartphone screen.

Let’s get very specific on your settings... did you have it set to some default quality of 99%? So that each save cut off more data, not from the act of saving, but because you told it to compress again?

You can see the settings of the JPEG in the screenshot. Maximum quality is used. Even with maximum quality, there will be loss in information. A JPEG image will always be compressed

:facepalm: I didn’t think to zoom. Interesting that it would even reprocess it if it didn’t detect a change.

It's very simple. RAW is a capture/editing format, TIFF is a editing/delivery format and Jpeg is a delivery format. Use each for it's strengths. Capturing Jpegs is also fine as long as you *really* need the speed (news/sport etc), otherwise shoot raw.

Nothing wrong with Jpegs at all, in fact they are perfect for 'output'. But only as finished images, those not intended to be edited further. ALL of my published work for the past 20 years has been delivered as good quality Jpegs.

True... absolutely true

Exactly this.

That is nothing new. The degradation of jpeg, while open and save, is well known.

Indeed. Still, a lot of people don't realize it will affect the image that much

wow, but what about PNG format. Is it better or the same?

I do not know. I did not test that file format

PNG is lossless so it won't have the same issues.

Apparently one factor is that Photoshop tries to do some magic when opening a JPEG file to try to reduce JPEG artifacts. When iterating the combination of JPEG lossy compression and Photoshop's magic fix, you end up with an unstable system. Otherwise, JPEG on its own would converge to a fixed point that would not have these types of artifacts. You can find a good discussion at https://www.hackerfactor.com/blog/index.php?/archives/355-How-I-Met-Your...

I don't know what you mean by converging to a fixed point. I only see what is happening, and what a lot of JPEG photographers can run into if they're not careful

The way JPEG saves storage and loses information is essentially by rounding numbers. The idea is that normally, if you round the numbers multiple times, it still rounds to the same number and the image stops changing. It's a little more complex than just rounding numbers because it rounds numbers in a special representation (called Discrete Cosine Transform), so things may still change for a few iterations of open/save, but then it should stay at a fixed image, not go crazy like it does. But because photoshop does some extra stuff each time you open an image, the image keeps changing and not in a good way. So it's not just JPEG's fault, it's really JPEG+Photoshop.

I might be mistaken, but do you say it is just Photoshop and not the JPEG compression that is visible in my example? I think if there is compression, you throw away information. If you open that compressed file, the information that was lost has to be calculated again, because it does not exists anymore. If that is done multiple times, the errors will increase, isn't it? If there is a fault margin of 2% in JPEG compression, saving again will have again that 2% fault margin. Together that is 4%
I don't believe it is 2%, but if I see the result, it is enough to produce this result.
I wonder what PS does to the image when opening it. Do you know what that is?

I'm saying it's the combination of the two. Again, the main compression mechanism here is rounding of numbers. Say you decide to save space by dropping the last digit of your numbers. You start with a pixel value of 233. You round it to 230 and only save the first two digits (23), hence saving 1/3 of storage space. Then when you open the file, you read 23, but you know you dropped a digit and you reconstruct a value of 230. You made an error of 3, that's the information loss. If you save again, 230 gets rounded to the same number 230 and the compression loss does not accumulate. It's more messy with JPEG because the numbers you round are not directly pixel values but same idea.

Now the problem is that when photoshop reads your image, it tries to be smarter than what the JPEG standard says you should do. JPG says: just add zero to the first two digits, that's it (again I am way oversimplifying here). Photoshop thinks: JPG tells me that the first two digits are 23 and I am going to try to be super smart to guess what the true number is and make things "look better" based on secret sauce. In many cases it may guess, say, 229 or 234 and that's fine. But it may go overboard and guess 237 (apparently it does not even try to guess a number that actually rounds to 23.) Now when you save, it gets rounded to 240 instead of 230. And this kind of error apparently tends to accumulate, because the next round your 240 may be guessed as, say, 246m, etc.

I understand JPG pretty well, I teach its basics at MIT, and I had no idea this problem with Photoshop occurred until you pointed it out. Thanks!

Ah. If I understand correctly, the loss should occur only once, until a round number is reached (oversimplifying this also) It means if I would try the experiment again with a program that is not Photoshop, the example I showed would not happen, at least is such an extreme manner.
Which program should you advise? Because I would love to test that

Correct. Except as you say it's simplified and it may change a few times because you do the rounding in a DCT representation, then convert back to pixel representation, which changes things a little bit. But after a few times it shouldn't budge.
I would start with free options. According to the link I posted, Gimp also tries to do something but not as aggressively as photoshop. Maybe darktable or irfan view?
I should try to code it with libjpeg, which is the library most people use to save JPEG. Then at least I'd know exactly what is going on.

I can make run for it in Irfanview. Let's see of I can find the time.

Jpeg doesn't work in absurdly unlikely use case. News at 11

Lots of people still edit jpgs (both my mom and mother-in-law!). Back in the day, Picassa was an easy editing tool and I believe early versions saved a new jpg for every edit. My mom still misses that tool... I've often wondered what the degradation would look like, thanks for posting, I think I would have given up after 10 saves, let alone 99!

It was fun to do... once. Never again :)

This pops up once in a while as if it's a new topic.

Import, LR process, export full res JPG 12.
Wetransfer to client. All happy.

Then you get the ones that ask for 300dpi TIF. (300dpi being that magical number that they think means high quality) You send that, then they ask for something smaller because they can't open the 5gb Wetransfer on their phone.

So you export as 5000px on the long edge JPG 12 and it's printed in a magazine just fine.

Now, If it's going to pass a file onto my editor for extensive processing, that'll get exported at their preference because they work with the difference.

JPEG works fine, I agree. And in normal cases you won't save it over and over again like my example. But it is good te see what happens if you would.

Ummmm... jpeg was never intended to be a 'general purpose' format. It was- and still is- specifically intended to be a device-independent standardized interchange format for continuous tone photographs. Part of this is file compression to allow for efficient network interchange. Jpeg is still overwhelmingly successful at this. It is the world wide interchange standard and, given its ubiquity, is not going anywhere soon. At best, whatever alternative formats are developed- heif/heic were mentioned- would simply coexist with jpeg in much the same way rtf/doc/docx/odt coexist in the word processing world. It should be noted that the intent always was- and still is- that the photograph would be processed in another format and, before being sent or posted, converted to jpeg. It would seem this would be tiff or bmp formats. It should also be noted that the jpeg format is one of the recommended formats for sustainability by the Library of Congress. Again a quality of 100 is recommended. Some photographers do process in jpeg. They should maintain as high a quality setting as possible- 100 if available- and limit the number of processing sessions to two or three. Those processing raw files have one session available before having to convert to another format. It would seem that tiff would be the format of choice here.

Jpegs are usually saved at a little over 80% quality. But I would like to know if any degradation occurs if you save it at 100% quality. "100%" seems to imply that it is lossless.

More comments