The secret of shrinking graphic file size is reduction of bit depth, resolution, and dimension while preserving image quality. Bit Depth Reduction For palette-based indexed formats, such as GIF and PNG, the lower the bit depth, the smaller the file. Lossy, full color RGB formats like JFIF, do not benefit from bit depth reduction as file size is primarily related to quality. One way to avoid these problems is to deliberately work in a 256-color palette.
Some formats support even higher bit depths, useful for medical imaging or smooth transparencies.
Indexed images refer to each color by its position in the palette. Finding the right color palette that provides the best image quality on 8-bit machines is an art form in itself, and can dramatically affect the appearance and size of your graphics. Compression Compression algorithms are used to re-encode data into more compact representations of the same information. In other words, fewer words are used to say the same thing. For GIFs and PNGs, the more linear change there is, the less efficient the compression.