Although MapScript can generate the map in any desired image format it sufficient to only consider the three most prevalent ones: JPEG, PNG, and GIF.
JPEG is an image format that uses a lossy compression algorithm to reduce an image’s file size and is mostly used when loss of detail through compression is either not noticeable or negligible, as in most photos. Maps on the other hand mainly consist of fine lines and areas solidly filled in one colour, which is something JPEG is not known for displaying very well. In addition, maps, unless they include some aerial or satellite imagery, generally only use very few different colours. JPEG with its 24bit colour depth capable of displaying around 16.7 million colours is simple not suitable for this purpose. GIF and PNG however use an indexed colour palette which can be optimized for any number (up to 256) of colours which makes them the perfect solution for icons, logos, charts or maps.
Although GIF shows a quantitative as well as qualitative advantage over PNG when generating maps that contain full coloured remote sensing imagery, PNG is the clear quantitative winner in terms of generated file sizes for maps with or without additional monochrome imagery and should therefore been the preferred image format. If the mapping application however can also display fullcolour aerial or satellite imagery, the output file format can be changed dynamically to either GIF or even PNG24 to achieve the highest possible image quality.