Choosing a format

PHP gives you a good selection of options when choosing an output format: PNG, GIF, JPEG, and WBMP to name a few. Normally, though, one is best for a certain type of image.

Generally speaking, for high-quality images with many colours or a lot of detail, the JPEG format should be preferred. JPEG saves in true colour and allows you to set the compression ratio in order to get the best trade-off between size and quality. PNGs, on the other hand, work best as a replacement for GIFs, and as such work well using limited colours. They also offer alpha transparency, and really teensy file sizes.

So, put as simply as possible: for photographs, prefer JPEGs, and for everything else, prefer PNGs. Just as an aside, and at the risk of starting a flame war, the correct pronunciations are: "ping", "jay-peg", and "jif". Note that WBMP is not Windows Bitmap as you might have first thought - it stands for Wireless Bitmap and is designed for use in limited bandwidth situations.


Next chapter: Getting arty >>

Previous chapter: Creating new images

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.