This is a sample image 8x8 pixels encoded with minimum JPEG compression in Paintshop Pro v5.0 The image is not very suitable for JPEG consisting of highly saturated colour blocks 2x1 pixel wide. The intention is to demonstrate the sort of artefacts which can occur in practice in a very much simplified form. The problem is with heavy saturated colours and sharp discontinuities which are difficult for colour subsampling to represent accurately. It has actually done remarkably well in preserving luminance information, but when enlarged the difference between the original image and JPEG is more obvious. The artefacts are present but at a pretty low level even in such a difficult image.
Note that under normal circumstances and typical magnifications these would not be visible. Many commercial monitors are unable to resolve the differences at 1x or even 2x magnification. Images have been converted to GIF's for display purposes here using exact palette colour matching (there are only 64 pixels in the image). There are 4 colours in the orginal test image, and 40 distinct shades in the resulting JPEG reconstruction.
Original 1x 2x 4x 8x
JPEGs 1x 2x 4x 8x
Real photographic images seldom have such sharp transitions between regions and so the JPEG compression of real colour photographic images usually works much better than the above test images might imply. The moral of the tale is obviously that it is unwise to use JPEG compression with colour subsampling for line art colour images. However, the limitation is not with the JPEG standard - images can be saved as JPEG without subsampling.
The IJG CJPEG utility with suitable command line options or the PhotoShop JPEG codec at levels 6 and above can create full colour sampled JPEGs.
JPEGs. 1x 2x 4x 8x
The extra colour fidelity makes PhotoShop a good choice for saving scanned images as highest quality JPEG files. More recently PaintShop Pro v8.0 also permits options to save JPG files with a range of colour subsampling options. Unfortunately the chroma subsampling is seriously broken causing systematic errors in the JPEG encoding and it still doesn't do optimised Huffman coding. The following pure red and pure blue pokerdot pattern demonstrates the faulty encoding of chroma subsampling vividly even at maximum quality.
Original 1x 2x
IJG Codec 2x2 subsampled1x 4x
The loss of red blue contrast is an unavoidable consequence of chroma subsampling, but from a distance and on a properly adjusted monitor the two images above should look similar once you can no longer resolve the colours of the individual pixels. Compare that with the same source image encoded by PSPro v8 below:
PSP v8 2x2 subsampled 1x 4x
PSP v8 2x1 subsampled 1x 4x
A page addressing the vexed question of JPEG Generational Losses or what happens when you repeatedly open, decode and reencode save an image using JPEG. The short answer is that for a while the image will always be worse after each cycle of decoding and re-encoding even if the compression settings are ideentical every time. The first save causes the greatest loss of fidelity. But after a while the image will settle down block by block to the nearest stable attractor. That is an image in RGB space that when encoded gives self consistent JPEG coefficients that decode to give a new RGB image that is close enough to the previous generation that no further degradation occurs. This stable attarctor image may lose considerable amounts of colour saturation if chroma subsampling is used. And of course if you alter the lossy compression settings even slightly the result is another disastrous loss of quality.