public function ReduceColorDepth(&$gdimg, $colors = 256, $dither = true) { $colors = max(min($colors, 256), 2); // ImageTrueColorToPalette usually makes ugly colors, the replacement is a bit better //ImageTrueColorToPalette($gdimg, $dither, $colors); phpthumb_filters::ImageTrueColorToPalette2($gdimg, $dither, $colors); return true; }