How to manipulate images using php

Asked By 0 points N/A Posted on -

Hello, im currently trying to develop a new captcha system for websites using php, html and javascript and i would like to know how i can manipulate images using php especially ones involving distortion, rotation, resizing or scaling, color filtering and image cropping. Please help as soon as you can, i would really be grateful for quick response

Answered By 0 points N/A #164283

How to manipulate images using php


There are basically 3 types of captcha first one and widely used is image captcha , second is mathematical captcha and last one is vice captcha.

First Generate captcha image





$im = imagecreatetruecolor(50, 24);

$bg = imagecolorallocate($im, 22, 86, 165); //background color blue

$fg = imagecolorallocate($im, 255, 255, 255);//text color white

imagefill($im, 0, 0, $bg);

imagestring($im, 5, 5, 5,  $code, $fg);

header("Cache-Control: no-cache, must-revalidate");

header('Content-type: image/png');





Put captcha image in html form




<title>Test Form</title>



<form action="validate.php" method="post">

Enter Image Text

<input name="captcha" type="text">

<img src="captcha.php" /><br>

<input name="submit" type="submit" value="Submit">





Now validate Captcha response





echo "Correct Code Entered";

//Do you stuff




die("Wrong Code Entered");




Login/Register to Answer

Related Questions