SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: GD Questions
-
Jul 6, 2006, 02:35 #1
- Join Date
- Nov 2005
- Location
- The Netherlands
- Posts
- 205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
GD Questions
First, I have some problems when creating security images. For some reason I always have this, when I create too many characters or things with colors the latest characters just turn grey. Heres an example (yes the captcha is weak but its just for showing)
and another, in some captchas I see that text gets distorted, twisted and such. how do I do that?
Greets and thanks in advance
Taking over the web one pixel at a time.
Currently working @ CodeCreators
-
Jul 6, 2006, 06:02 #2
You need to post some code.
Location: Alicante (Spain)... Hot and Sunny...
Texas Holdem Poker Probability Calculator | DNS test
Avatars | English Spanish Translation | CAPTCHA with audio
Email | PHP scripts | Cruft free domain names | MD5 Cracker
-
Jul 7, 2006, 07:15 #3
- Join Date
- Nov 2005
- Location
- The Netherlands
- Posts
- 205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
K, but the wierd thing is that it happens with every color thing I make....
PHP Code:function writeCode(){
for($i = 0;$i < $this->iLength;$i++){
$sFont = "font.ttf";
$this->iSize = rand(14,20);
$sChar_y = rand($this->iHeight-15,$this->iHeight-5);
$iAngle = rand(-10,10);
$a = rand(150,255);
$b = rand(150,255);
$c = rand(150,255);
$d = rand(0,150);
$e = rand(0,150);
$f = rand(0,150);
$oColor = imagecolorallocate($this->oImage,$a,$b,$c);
$oColor2 = imagecolorallocate($this->oImage,$d,$e,$f);
imagettftext($this->oImage,$this->iSize,$iAngle,15+($i*$this->iSpacing),$sChar_y+1,$oColor2,$sFont,$this->aCode[$i]);
imagettftext($this->oImage,$this->iSize,$iAngle,15+($i*$this->iSpacing)+1,$sChar_y,$oColor2,$sFont,$this->aCode[$i]);
imagettftext($this->oImage,$this->iSize,$iAngle,14+($i*$this->iSpacing),$sChar_y,$oColor,$sFont,$this->aCode[$i]);
}
}
Taking over the web one pixel at a time.
Currently working @ CodeCreators
-
Jul 7, 2006, 18:54 #4
- Join Date
- Nov 2005
- Location
- The Netherlands
- Posts
- 205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
nobody?
Taking over the web one pixel at a time.
Currently working @ CodeCreators
-
Jul 8, 2006, 00:34 #5
Your code is OOP and you have only posted one method. That makes it impossible for anyone to run the code.
Location: Alicante (Spain)... Hot and Sunny...
Texas Holdem Poker Probability Calculator | DNS test
Avatars | English Spanish Translation | CAPTCHA with audio
Email | PHP scripts | Cruft free domain names | MD5 Cracker
-
Jul 8, 2006, 00:41 #6
- Join Date
- Nov 2005
- Location
- The Netherlands
- Posts
- 205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
K Ill give the full code, just didnt think it mattered:
PHP Code:class captcha{
var $oImage;
var $iWidth;
var $iHeight;
var $iLength;
var $iSize;
var $iSpacing;
var $aCode;
function setVars(){
$this->iWidth = 100;
$this->iHeight = 35;
$this->iLength = 4;
$this->iSpacing = ($this->iWidth/$this->iLength)-6;
}
function setImage(){
$this->oImage = imagecreate($this->iWidth,$this->iHeight);
imagecolorallocate($this->oImage,230,230,230);
}
function setBorder(){
$oColor = imagecolorallocate($this->oImage,160,160,160);
imageline($this->oImage,0,0,0,$this->iHeight,$oColor);
imageline($this->oImage,0,0,$this->iWidth,0,$oColor);
imageline($this->oImage,$this->iWidth-1,0,$this->iWidth-1,$this->iHeight-1,$oColor);
imageline($this->oImage,0,$this->iHeight-1,$this->iWidth-1,$this->iHeight-1,$oColor);
}
function genCode(){
$aChars = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9");
$iTotal = count($aChars);
for($i = 0;$i < $this->iLength;$i++){
$x = rand(1,$iTotal);
$aChar = $aChars[$x];
$this->aCode[$i] = $aChar;
}
return $this->aCode;
}
function genNoise(){
imagefilter($this->oImage,IMG_FILTER_MEAN_REMOVAL);
imagefilter($this->oImage,IMG_FILTER_EDGEDETECT);
}
function writeCode(){
for($i = 0;$i < $this->iLength;$i++){
$sFont = "font.ttf";
$this->iSize = rand(14,20);
$sChar_y = rand($this->iHeight-15,$this->iHeight-5);
$iAngle = rand(-10,10);
$a = rand(150,255);
$b = rand(150,255);
$c = rand(150,255);
$d = rand(0,150);
$e = rand(0,150);
$f = rand(0,150);
$oColor = imagecolorallocate($this->oImage,$a,$b,$c);
$oColor2 = imagecolorallocate($this->oImage,$d,$e,$f);
imagettftext($this->oImage,$this->iSize,$iAngle,15+($i*$this->iSpacing),$sChar_y+1,$oColor2,$sFont,$this->aCode[$i]);
imagettftext($this->oImage,$this->iSize,$iAngle,15+($i*$this->iSpacing)+1,$sChar_y,$oColor2,$sFont,$this->aCode[$i]);
imagettftext($this->oImage,$this->iSize,$iAngle,14+($i*$this->iSpacing),$sChar_y,$oColor,$sFont,$this->aCode[$i]);
}
}
function createImage(){
$this->setVars();
$this->setImage();
$this->setBorder();
$this->genCode();
$this->writeCode();
//$this->genNoise();
imagepng($this->oImage,"image.png");
imagedestroy($this->oImage);
return implode('',$this->aCode);
}
}
Taking over the web one pixel at a time.
Currently working @ CodeCreators
-
Jul 9, 2006, 04:08 #7
- Join Date
- Nov 2005
- Location
- The Netherlands
- Posts
- 205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
:O need help
Taking over the web one pixel at a time.
Currently working @ CodeCreators
Bookmarks