function frame_picture ($image, $thickness
{
$color = get_average_color$image);
$image2 = imagecreatetruecolorimagesx$image)+$thickness$thickness
imagesy$image)+$thickness$thickness);
$r = hexdecsubstr$color, 0, 2));
$g = hexdecsubstr$color, 2, 2));
$b = hexdecsubstr$color, 4, 2));
$color = imagecolorallocate$image2, $r, $g, $b);
imagefilledrectangle$image2, 0, 0, imagesx$image2)-1, imagesy$image2)-1, $color);
imagecopy$image2, $image, $thickness, $thickness, 0, 0, imagesx$image)-1, imagesy$image)-1);
return $image2
}