PHP obtains the CAPTCHA code picture to the local, supports the PNG, GIF, JPG three format authentication code. In the implementation, PHP judge picture format is the use of PHP built-in Exif_imagetype function, is really more convenient, learn PHP may wish to refer to the following code:
View SOURCEPRINT?01
02header ("Content-type:image/png");
03set_time_limit (0);/Set timeout time
04$url = $_get[' url '];
05$url = "Http://vcer.baidu.com/verify";
06if (Empty ($url)) {
echo "No pictures";
Die;
09}
10$imginfo = getimagesize ($url);
11$type = Exif_imagetype ($url);
12$IMGW = $imginfo [0];
13$IMGH = $imginfo [1];
14$BG = Imagecreatetruecolor ($IMGW, $IMGH);
15if ($type ==imagetype_gif) {
$image = Imagecreatefromgif ($url);
17}elseif ($type ==imagetype_jpeg) {
$image = Imagecreatefromjpeg ($url);
19}elseif ($type ==imagetype_png) {
$image = Imagecreatefrompng ($url);
21}
22imagecolorallocate ($image, 255,255,255);
23imagecopy ($BG, $image, 0,0, 0,0, $IMGW, $IMGH);
24imagedestroy ($image);
25ImagePng ($BG);
26?>