asmith Posted January 9, 2008 Share Posted January 9, 2008 making captcha image with php is so easy . you can set the text font, lines , color ... i see a captcha here : http://www.aoaforums.com/forum/register.php?do=register it is so colorful , background change every time. the thing i really really want to learn is : 1.how can i rotate "each" letter or number ? for example rotate 30` . or 45` . 2. how about the background image ? i use solid color for the captcha background, how do they use background image ? 3.seems they've give each letter or number one different color ? here's the some peice of code i usually use : <?php // create the image resource $image = ImageCreatetruecolor(150,150); // set colors $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); // set background imagefill($image, 0, 0, $white); // set text imagettftext($image, 50, -10, 10, 45, $black, 'font.ttf', $the_code); // set lines imagesetthickness($image,2); imageline($image, 23, 2, 130, 2, $black); // created image imagejpeg($image); imagedestroy($image); ?> Quote Link to comment Share on other sites More sharing options...
aschk Posted January 9, 2008 Share Posted January 9, 2008 You can rotate an image using imagerotate(), however what I think you "might" need to do is, create an image for each letter, rotate each letter-image, and them merge all images onto a final image. Try that. I've never done this technique before (always just been satisfied with basic captcha + silly fonts) but there is no reason why it shouldn't work. Quote Link to comment Share on other sites More sharing options...
asmith Posted January 9, 2008 Author Share Posted January 9, 2008 will be the size of the final imgae so high ? and how do i merge images together? Quote Link to comment Share on other sites More sharing options...
aschk Posted January 9, 2008 Share Posted January 9, 2008 You create a truecolorimage (whatever height/width you want) and super impose the other images onto it using the imagecopyresized() function. See http://uk2.php.net/manual/en/function.imagecopyresized.php Quote Link to comment Share on other sites More sharing options...
asmith Posted January 9, 2008 Author Share Posted January 9, 2008 thanks for the idea, i'll give it a try! you know how to set a background image for captcha image instead of a solid color ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.