Да кстати, ИМХО использовать лучше $b->drawJpeg(); ( причем установить ему низкой качество ) ибо качество картинки становиться ниже, и текст опознается ботами хуже. хотя может это и бред %)
upd
Немного модифицировал этот скрипт:
| Код | <?PHP class Button { var $image; public function __construct($width, $height, $label, $font) { $this -> image = imagecreate($width, $height); $colorBody = imagecolorallocate($this -> image, 0x99, 0x99, 0x99); $colorShadow = imagecolorallocate($this -> image, 0x33, 0x33, 0x33); $colorHighlight = imagecolorallocate($this -> image, 0xCC, 0xCC, 0xCC); $colorBalck = imagecolorallocate( $this->image, 0, 0, 0 ); imagefilledrectangle($this -> image, 1, 1, $width-2, $height-2, $colorBody); imageline($this -> image, 0, $height-1, $width-1, $height-1, $colorShadow); imageline($this -> image, $width-1, 1, $width-1, $height-1, $colorShadow); imageline($this -> image, 0, 0, $width-1, 0, $colorHighlight); imageline($this -> image, 0, 0, 0, $height-2, $colorHighlight); imageline( $this->image, imagesx( $this->image ), 0, 0, imagesy( $this->image ), $colorBalck ); $labelHeight = imagefontheight($font); $labelWidth = imagefontwidth($font)*strlen($label); $labelX = ($width - $labelWidth)/2; $labelY = ($height - $labelHeight)/2; imagestring($this -> image, $font, $labelX+1, $labelY+1, $label, $colorShadow); imagestring($this -> image, $font, $labelX, $labelY, $label, $colorHighlight); imageline( $this->image, 0, 1, imagesx( $this->image ) , imagesy( $this->image ), $colorBalck ); return $label; } public function drawPNG() { header("Content-type: image/png"); imagepng($this -> image); } public function drawJPEG() { header("Content-type: image/jpeg"); imagejpeg($this -> image, '', 80 ); } public function drawGIF() { header("Content-type: image/gif"); imagegif($this -> image); } } $alphavit = 'qwertyuiopasdfghjklzxcvbnm';
for( $i = 0; $i<6; $i++) { $word .= $alphavit{ rand(0, strlen( $alphavit )-1 ) }; }
$b = new Button ( '100', '30', $word, 4 ); $b->drawJpeg(); ?>
|
|