/** * Function for finding a pixel's RGBa values. */ function getPixelColor(ImageInterface $image, $x, $y) { $toolkit = $image->getToolkit(); $color_index = imagecolorat($toolkit->getResource(), $x, $y); $transparent_index = imagecolortransparent($toolkit->getResource()); if ($color_index == $transparent_index) { return array(0, 0, 0, 127); } return array_values(imagecolorsforindex($toolkit->getResource(), $color_index)); }