Image compression applies principals and established algorithms of Data compression on digital images. The idea, basically, is to reduce data redundancy in the image data by removing multiple instances of the same data and replacing with locational information. Image compression can be either lossy or lossless, depending on what output you need. Lossless compression is the preferred method for artificial images such as technical drawings, icons or comics, while lossy methods are usually applied to natural images like photos in applications where minor loss of fidelity is acceptable to achieve a substantial reduction in bit rate.
Methods for Lossless Compression
There are various methods of lossless compression. These are run length encoding, DPCM or differential pulse-code modulation, Predictive coding, entropy coding, adaptive dictionary algorithms like LZW or Lempel-Ziv-Welch, and Deflation. Of these, LZW is especially well-known. It is used in GIF and TIFF. Created by Abraham Lempel, Jacob Ziv, and Terry Welch, it builds a string translation table from the data being compressed, and translates this into lossless and optimally compressed image data that can be used to recreate the image losslessly at a different time. Run Length coding is used as a default method in PCX and one of the possible methods in BMP, TGA and TIFF.
Methods for Lossy Compression
Various methods, including reducing the color space to the most common colors in the image, chroma subsampling that reduces half or more of the chrominance of an image, Transform coding and fractal compression are used to lossy-ly compress images. Of these, the most commonly used method is transform coding. It uses a Fourier series based transform such as DCT(discrete cosine transform) or the wavelet transform, followed by quantization and entropy coding. Though lossy compression may reduce image quality, it can reduce image size considerably.