$image = imagecreatetruecolor(100, 50);
$border_color = imagecolorallocate($image, 0, 0, 0);
function drawBorder(&$image, &$border_color, $thickness = 1)
{
	$x1 = 0;
	$y1 = 0;
	$x2 = imagesx($image) - 1;
	$y2 = imagesy($image) - 1;
	for($i = 0; $i < $thickness; $i++)
	{
		imagerectangle($image, $x1++, $y1++, $x2--, $y2--, $border_color);
	}
}
drawBorder($image,$border_color, 1);