<?php
function get_color($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;
}
?>