It will change each time you save it, even at the maximum quality level, because the JPEG compression mechanism does not record actual pixel RGB values; it approximates them. When a file is saved to JPEG, something like the following occurs (this is a gross oversimplification): First, the RGB levels are converted to YCrCb values, because RGB values aren’t stored. Then the bitmap is broken up into segments, and each segment is assigned the amount by which its average YCrCb value differs from that of the entire bitmap; then each segment is then broken up into more segments, each of which is assigned the amount by which its average YCrCb value differs from that of its parent; etcetera, recursively, to a degree that depends on the quality level. When this file is then opened, pixel YCrCb values are created based on the averages for adjoining subsegments through the reverse of the recursion process, but you will never get exactly the same array of YCrCb values in the original. Close enough to look the same, yes. Pretty damn close, in the case of maximum quality, but not the same. And then the YCrCb values are converted to RGB, resulting in additional rounding errors.
I created a 600×900 pixel 8-bit image consisting of a radial rainbow gradient, a bunch of pencil lines in several colors, some brush strokes in black and white at various opacities, some blurring, etc. I saved it as a PSD and then as a max-quality JPEG, first.jpg <
http://camsul.com/first.jpg>. I closed and then opened the first.jpg and saved it as second.jpg <
http://camsul.com/second.jpg>, at max-quality. Did the same again to create third.jpg <
http://camsul.com/third.jpg>.
Now I dragged a copy of second.jpg onto first.jpg and set the blend to difference. It looked solid black. I added a Threshold adjustment layer. With the threshold set to 2, representing pixels differing by 2 units, now the result <
http://camsul.com/first-second-2.gif> looks like the night sky, with widely separated white pixels scattered randomly. The histogram (after refreshing the cache) tells me that out of the 540,000 pixels, 414 are white and 539,586 are black. So 99.92% of the pixels in the image are unchanged by 2 units or more, while 0.08% are changed by at least 2 units. Changing the threshold to 1, the result <
http://camsul.com/first-second-1.gif> is a ghostly pattern covering virtually the whole image, except large solid-color areas, with an array of black and white dots. The histogram says 449,010, or 83.15%, are black, representing unchanged pixels, while 90,990 pixels are white, meaning they have changed by at least one unit.
Now let’s compare third.jpg to second.jpg, using the same technique. Here are the results: 1 unit <
http://camsul.com/second-third-1.gif>: 477,295 black (unchanged), 88.39%; 62,705 white (changed)
2 unit <
http://camsul.com/second-third-2.gif>: 539,764 black (unchanged), 99.96%; 236 white (changed)
Comparing third.jpg to first.jpg shows that the further degradation is in fact cumulative. At a threshold of 1, only 74.77% of the pixels (403,778) were unchanged, and at a threshold of 2, 99.65% (538,100) were unchanged. (I’m not going to bother posting the threshold graphics; you can recreate them if you doubt me.)
Again, this is all at maximum quality level JPEG (12). A demonstration that the cumulative differences would be much worse at lower quality levels is intuitively obvious, and is left to the reader.