What's "JPEG rot"? First off, relax. If you've got JPEG files on your computer and you let them sit there, nothing will happen to them. It isn't that kind of rot, thank goodness. What's more, you can look at your JPEG files in an image viewer or your graphics editor as many times as you want, and nothing will happen to them either. It's only when you open JPEG files in your graphics editor and save them again that you can run into the dreaded "JPEG rot".
Let's suppose you've taken a picture of your dog and you want to use it on your website. So you get the image from your camera or scanner and save it as a JPEG file. The first thing you do is get rid of the red eye from your flash. Then you crop the picture, tweak the brightness and contrast, do a little clone brushing to get rid of dirt spots on your carpet, resize the image, and put a nice border around it.
Since you remember that all operating systems and programs can crash, you save pretty often during all this manipulation. And that's what gets you into trouble. Because JPEG has lossy compression, that means every time you save the file you lose some data. Every time you save a JPEG file, it gets a little worse. And eventually you start noticing that the nice clean, sharp image you started with has become grungy and worn looking. That's called "JPEG rot." You can see some examples in the "Reader's Comments" section of Gordon Richardson's article on JPEG compression.
Now most good graphics programs keep an internal image around and save that each time, so you're only going to make your image worse once per session. But if you're like us, you'll come back to your images hours or days later and tweak them some more, so by the time the image is ready for the web, you might have played around with it 10 times or even more. Even worse, some people have buttons or icons that are all pretty much the same shape and color, and what they do is take the last button they edited and change the text to the name of the new section they just wrote. And every time you open and save a JPEG file, it gets a little bit worse.
"But wait," we hear you say, "we save our images at 100% quality, 0% compression. So we're immune." Not so fast, pixel-breath. In fact, every level of JPEG compression is lossy. At lower compression numbers (higher quality numbers) it just takes longer to show up. But if you save it enough times in a row, it'll rot. That's just the way JPEG's lossy compression works.
There is some consolation, though. According to Tom Lane, after you've saved an image 100 times or so, that's as bad as it's ever going to get.
Is there a cure for JPEG rot? Sure. If saving a JPEG file over and over again makes it worse, Don't save it as a JPEG! Save it in some other format! Easy as that. Pick some other file format that won't get worse every time you save it. Then later on, when you want to use it on your website, run off a copy as a JPEG file.
So you'll have a master file in some other format that you can work on to your heart's content, and a JPEG copy of your master file that goes out on your website. Every JPEG copy's just one step removed from your master, and if you pick the right format for your master, the master is going to stay clean pretty much no matter what you do to it (well, within reason).
Now what format do we know that has the millions of colors you get with JPEGs, but doesn't have the lossy compression that causes JPEG rot? Right — PNG! PNG is a great format for your master files. It's usually larger than the equivalent JPEG file, but it'll be a lot smaller than TIFF or Windows bitmap, the other two formats that might make sense.
So it looks like it's time to turn your old JPEG files into PNG files. You can't make them better, but at least you can stop from making them worse, and if you're lucky the damage you've done so far isn't noticeable yet.
But wait. If you've
got one of the better graphics programs, you've got a file format
that's even better than PNG. Photoshop saves .psd files
and Paint Shop Pro saves .pspimage files (before version
8 it saved .psp files). Those files let you keep
information about layers and masks and other effects and they
sometimes even let you undo what you did before the last save.
Sometimes those files are integrated with workspace files, which lets
you keep even more information.
The whole point of these files is to let you come back and pick up right where you left off, and that's exactly the way you should use them. Work on your master file, and when you've got the image just the way you want it, run off a copy for your website in JPEG or PNG or GIF format.
So if your graphics program has a native file format like Photoshop and Paint Shop Pro do, use that. If it doesn't, save the file as a full color PNG. Always work on the master file, so the file on your website is just a copy you made for the web. Voilla! No more JPEG rot.