The JPEG compression algorithm works by reducing the amount of information contained in an image. Compressing the same image multiple times leads to severe losses of quality, while the file size actually gets bigger! For this reason, storing an image in the JPEG compressed file format is not recommended for images that need to be processed further. Instead, one should always work with a lossless format, such as TIFF or PBM. Saving as .JPG should be the last step when an image is to be incorporated into a webpage or other presentation.
To demonstrate the effect of multiple compression steps, I took a normal chest radiograph from the Hammersmith Hospital PACS and converted it to PGM (Portable Graymap) format. The uncompressed filesize was 3264 kB, the pixel dimensions were 1755x1902 (width x height). I loaded this file into an image manipulation program (The Gimp), scaled it to one third of the original pixel resolution (585x634), and saved it as PNG (Portable Network Graphics, a lossless format). I then marked the file graphically with a "1", saved it as JPG with a quality setting of 50%, converted to PNG, reloaded the PNG, marked it with a "2", saved as JPG, converted to PNG, and so forth. The resulting images are shown below.
Note on browser compatibility: the PNG format used in this page doesn't seem to be supported very well by Netscape 4.75 and older versions. If the images look strange, please download them and view them with an image viewer or editor. Here's a zip file containing all images: jpgdemo.zip
The image shown as a (lossless) PNG.
File size: 148 kB
First compression step.
File size: 13679 Bytes
Third compression step.
File size: 15725 Bytes
Eighth compression step.
File size: 16169 Bytes
Detail of uncompressed image.
Detail of first compressed image.
Detail of eighth compressed image. Note how the rib contours suffer particularly badly.