function add_transparency ($image, $percent
{
$x = imagesx$image);
$y = imagesy$image);
$image2 = image_create_alpha$x, $y);
imagecopy$image2, $image, 0, 0, 0, 0, $x, $y);
imagesavealpha$image2, true);
if ($percent>0) {
for ($ii=0;$ii$x$ii++) {
for ($jj=0;$jj$y$jj++) {
$c = imagecolorat$image2, $ii, $jj);
$r = ($c >> 16) & 0xFF;
$g = ($c >> 8) & 0xFF;
$b = $c & 0xFF;
$alpha = ($c >> 24) & 0xFF;
$c = imagecolorallocatealpha$image2, $r, $g, $b, $alpha+($percent/100*(127-$alpha)));
imagesetpixel$image2, $ii, $jj, $c);
}
}
}
return $image2
}