JPEG compression loses some data in the encoding process. In JPEG compression, the image gets divided into small bolcks of 8 pixels by 8 pixels. Each 8x8
block is run through a
discrete cosine transform. Once the image is in the
frequency domain, the coefficients get rounded off to reduce the size of the resulting file. Because of the rounding, the reconstituted image is never
exactly the same as the original. It has some
visual artifacts, which may be nearly invisible, or may be flagrantly obvious, depending on the original image and the amount of compression (and thus, rounding) done to the image.
Most of these artifacts appear where there is a
sharp edge between light and dark in an image. Imagine (or if you're really into this sort of thing, make) a
jpeg image of a black and white
checkerboard, rotated
45 degrees so that the lines in the grid don't line up with the compression blocks. If you look closely, you can see a visual "echo" of the line a few
pixels away from the real line. Since
compression is done seperately on the each
YUV channel seperately, (see
converting RGB to YUV for more info on what the Y, U, and V channels are) the "echo" may look like a faint rainbow that runs parallel to the real line. There may also be a generally "
fuzzy" look to lines that should be hard and sharp. An image that goes from
white to
black in the space of one or two
pixels has a very high frequency over that area, and since representing high-frequency information takes a lot of bits, these high frequency spikes sometimes get chopped off by
overzealous compression algorithms.
The moral of this story? Don't crank your JPEG compression way up! :-) Image quality will suffer. Oh, and use
PNG (not
GIF, they have
other problems)!) for line art or things with only a few colors. JPEG is best suited to photos and full-color digital artwork.