/** * Takes samples from the given GD at 5 pixel increments * @param GD $gd The source image * @param integer $horizontal Number of samples to take horizontally * @param integer $vertical Number of samples to take vertically * @return array List of colours for each sample, each given as an associative * array with red, blue, green, and alpha components */ protected function sampleAreas(GD $gd, $horizontal = 4, $vertical = 4) { $samples = array(); for ($y = 0; $y < $vertical; $y++) { for ($x = 0; $x < $horizontal; $x++) { $colour = imagecolorat($gd->getImageResource(), $x * 5, $y * 5); $samples[] = ImageColorsforIndex($gd->getImageResource(), $colour); } } return $samples; }