The most commonly used digital image format is JPEG. It is universally compatible with viewers browsers, and image editing software, it allows photographic images to be compressed up to 10 to 20 times compared to the uncompressed original with very little visible loss in image quality.
To compress an original uncompressed image JPEG rearranges the image information into color and detail information, compressing color more than detail because our eyes are more sensitive to detail than to color, making the compression less visible to the naked eye. Secondly, it sorts the detail information into fine and coarse detail and discards the fine detail first because our eyes are more sensitive to coarse detail than to fine detail. This is achieved by combining several mathematical and compression methods.
JPEG allows you to make a trade-off between image file size and quality. JPEG compression divides the image in squares of 8 x 8 pixels which are compressed independently. Initially these squares manifest themselves through “hair” artifacts around the edges. Then, as you increase the compression, the squares themselves will become visible.
When editing an image in several sessions, it is recommended to save the intermediate image in an uncompressed format. If you save for instance an image in JPEG, close it, open it again and save it again in JPEG with the same quality setting, the file size will not reduce further, but quality will have degraded further. So only compress after all editing is done.
Cameras usually have different JPEG quality settings, such as FINE, NORMAL, etc. Unless you shoot in RAW, it is recommended to shoot in the highest available JPEG quality setting. Note however that some cameras will compress more than others, even at their highest JPEG quality setting.