void imagetruecolortopalette ( resource &image, bool dither, int num_colours)
The first effect is colour reduction, which is where a true colour image is converted to a paletted image. This is handled using the ImageTrueColorToPalette() function, which is a name so long you will be glad we have been capitalising each word in the image function names!
The function takes three parameters, which are an image to alter, whether to use dithering, and how many colours you would like in the final palette. It returns nothing, because the image is passed in as a reference for speed. The second parameter is critical to how the finished result looks: if you enable dithering by passing in true here, PHP will speckle the image to make it appear to have more colours than it actually has. Surprisingly, enabling dithering is not always a good thing - it makes the filesize larger, for example.