function round_corners ($image, $radius, $color, $transparency
{
$width = imagesx$image);
$height = imagesy$image);
$image2 = imagecreatetruecolor$width, $height);
imagesavealpha$image2, true);
imagealphablending$image2, false);
imagecopy$image2, $image, 0, 0, 0, 0, $width, $height);
$full_color = allocate_color$image2, $color, $transparency);
// loop 4 times, for each corner...
for ($left=0;$left<=1;$left++) {
for ($top=0;$top<=1;$top++) {
$start_x = $left * ($width$radius);
$start_y = $top * ($height$radius);
$end_x = $start_x$radius
$end_y = $start_y$radius
$radius_origin_x = $left * ($start_x-1) + (!$left) * $end_x
$radius_origin_y = $top * ($start_y-1) + (!$top) * $end_y
for ($x$start_x$x$end_x$x++) {
for ($y$start_y$y$end_y$y++) {
$dist = sqrtpow$x$radius_origin_x,2)+pow$y$radius_origin_y,2));
if ($dist>($radius+1)) {
imagesetpixel$image2, $x, $y, $full_color);
} else {
if ($dist$radius) {
$pct = 1-($dist$radius);
$color2 = antialias_pixel$image2, $x, $y, $full_color, $pct);
imagesetpixel$image2, $x, $y, $color2);
}
}
}
}
}
}
return $image2
}