this function essentially only draws four lines.
usually this is not a problem, but if you are using a color with an alpha value (with transparency), the four corner pixels will be darker than the connection lines. this is due to the fact, that the lines all start on the corner pixel, thus always two lines are on top of each other at the corner.
<?php
$col = imagecolorcreatealpha($img, $r, $g, $b, $transparency)
imagerectangle($img, $x1, $y1, $x2, $y2, $col );
$col = imagecolorcreatealpha($img, $r, $g, $b, $transparency)
imageline($img, $x1, $y1, $x2, $y1, $col ); imageline($img, $x1, $y2, $x2, $y2, $col ); imageline($img, $x1, $y1+1, $x1, $y2-1, $col ); imageline($img, $x2, $y1+1, $x2, $y2-1, $col ); ?>