Translucent text is not as simple as outlining or
shadowing, but it's not particularly hard. A translucent image is just something
partially invisible, or clear. This is done by drawing the image onto a buffer,
editing the buffer, and then merging the buffer back onto the original image.
01<?php 02 03functionimagettftexttransparent(&$im,$size,$angle,$x,$y,&$col,$fontfile,$text,$pct) 04{ 05// Get the image width 06$im_w=imagesx($im); 07// Get the image height 08$im_h=imagesy($im); 09// Create a buffer 10$new=imagecreate($im_w,$im_h); 11// Set a pixel down, so we can easily get the color 12imagesetpixel($im,$im_w-1,0,$col); 13// Get the color at that pixel 14$index=imagecolorat($im,$im_w-1,0); 15// Get the index of that color 16$rgb=imagecolorsforindex($im,$index); 17$r=$rgb['red'];// Get the red value 18$g=$rgb['green'];// Get the green value 19$b=$rgb['blue'];// Get the blue value 20// Allocate this color on the buffer 21$color=imagecolorallocate($new,$r,$g,$b); 22// Copy the old image onto the buffer 23$copy=imagecopy($new,$im,0,0,0,0,$im_w,$im_h); 24// Draw the text 25$text=imagettftext($new,$size,$angle,$x,$y,$color,$fontfile,$text); 26// Copy the buffer back onto the original image 27$merge=imagecopymerge($im,$new,0,0,0,0,$im_w,$im_h,$pct); 28// Destroy the buffer 29imagedestroy($new); 30} 31?>