PHP/Graphics Image/imagecolorexact
Color-retrieval functions could be combined into a custom function
<source lang="html4strict">
<?php
function getcolor($img, $red, $green, $blue) { $color = imagecolorexact($img, $red, $green, $blue); if($color == -1) { $color = imagecolorallocate($img, $red, $green, $blue); if($color == -1) { $color = imagecolorclosest($img, $red, $green, $blue); } } return $color; }
?>
</source>