View Full Version : imagegettftext transparent holes

10-27-2007, 09:48 PM
I created an image, made it transparent, drew a rounded rectangle on it and then wrote on it with imagegettftext - where the text is there are transparent holes.

$image = imageCreateTrueColor($width,$height);
imageSaveAlpha($image, true);
ImageAlphaBlending($image, false);

$transparentColor = imagecolorallocatealpha($image, 255-$r, 255-$g, 255-$b, 127);
imagefill($image, 0, 0, $transparentColor);

$background = imagecolorallocate($image, $br, $bg, $bb);

$textColor = imagecolorallocate($image, $r, $g, $b);

ImageRectangleWithRoundedCorners($image, 2,2,$width-2,$height-2,$radius-2,$background);
imagettftext($image, $fontSize, 0, $radius+4, $height-25, $textColor, $font, $text);

function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color) {
// draw rectangle without corners
imagefilledrectangle($im, $x1+$radius, $y1, $x2-$radius, $y2, $color);
imagefilledrectangle($im, $x1, $y1+$radius, $x2, $y2-$radius, $color);
// draw circled corners
imagefilledellipse($im, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color);
imagefilledellipse($im, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color);
imagefilledellipse($im, $x1+$radius, $y2-$radius, $radius*2, $radius*2, $color);
imagefilledellipse($im, $x2-$radius, $y2-$radius, $radius*2, $radius*2, $color);

exmaple here:

10-28-2007, 12:30 AM
Nancy ...

I didn't have time to actually experiment with your code,
but I found this:

They are able to put the text without holes.

Look for some other captcha scripts.