This article introduces the content of the PHP basic image processing, has a certain reference value, now share to everyone, the need for friends can refer to
<!--image processing--><?php//picture processing GD2 profile modification?><!--picture processing function to draw a picture--><?php//$img = Imagecreatetruecolor (5 //$red = Imagecolorallocate ($img, 255, 0, 0);//$green = imagecolorallocate ($img, 0, 255, 0);//$blu E = imagecolorallocate ($img, 0, 0, 255);//$pur = Imagecolorallocate ($img, 255, 0, 255);//$yellow = Imagecolorall Ocate ($img, 121, 72, 0); Imagefilledrectangle ($img, 0, 0, $green);//Imageline ($img, 0, 0,, $red);//Imageline ($i MG, 0, 0, $blue); Imagefilledellipse ($img, $yellow); Imagefilledellipse ($img, $, $blue); Imagejpeg ($img, ' haha.jpg ');//echo "<!--Development Verification Code (generate verification code)--><?php Check_code (); function Check_code ($width = $height, $num = 4, $type = ' jpeg ') {$img = Imagecreate ($width, $heigh T); $string = "; for ($i= 0; $i < $num; $i + +) {$rand = Mt_rand (0, 2); Switch ($rand) {case 0: $ascii = Mt_rand (48, 57); Break Case 1: $ascii = Mt_rand (65, 90); Break Case 2: $ascii = Mt_rand (97, 122); Break } $string. = sprintf ('%c ', $ascii); } imagefilledrectangle ($img, 0, 0, $width, $height, randbg ($img)); for ($i = 0; $i < $i + +) {Imagesetpixel ($img, Mt_rand (0, $width), Mt_rand (0, $height), ran Dpix ($img)); } for ($i = 0; $i < $num, $i + +) {$x = Floor ($width/$num) * $i + 2; $y = Mt_rand (0, $height-15); Imagechar ($img, 5, $x, $y, $string [$i], Randpix ($img)); } $func = ' image '. $type; $header = ' content-type:image/'. $type; if (function_exists ($func)) { Header ($header); $func ($IMG); }else {echo ' image type not supported '; } Imagedestroy ($IMG); return $string; } function randbg ($img) {return imagecolorallocate ($img, Mt_rand (255), Mt_rand (, 255), Mt_ran D (130, 255)); } function Randpix ($img) {return imagecolorallocate ($img, Mt_rand (0, +), Mt_rand (0, +), Mt_rand ( 0, 120)); }?><!--image scaling and clipping techniques--><?php $image = imagecreatefrompng (' fbb.png '); $percent = 0.1; List ($width, $height) = getimagesize (' fbb.png '); $new _width = $width * $percent; $new _height = $height * $percent; $new _image = Imagecreatetruecolor ($new _width, $new _height); Imagecopyresampled ($new _image, $image, 0, 0, 0, 0, $new _width, $new _height, $width, $height); Header (' Content-type:image/jpeg '); Imagejpeg ($new _image);? ><!--Image watermark processing--><?php $DST = imagecreatefrompng (' Http://img.php.cn/upload/course/000/ 000/002/5833ebba648cf229.png '); $SRC = imagecreatefrompng (' http://img.php.cn/upload/course/000/000/002/5833ebe90cc11285.png '); $DST _info = getimagesize (' 5833ebba648cf229.png '); $src _info = getimagesize (' 5833ebe90cc11285.png '); $DST _x = $dst _info[0]-$src _info[0]; $DST _y = $dst _info[1]-$src _info[1]; Imagecopymerge ($DST, $SRC, $dst _x, $dst _y, 0, 0, $src _info[0], $src _info[1], 100); Header (' content-type:image/png '); Imagepng ($DST); Imagedestroy ($DST); Imagedestroy ($SRC);? ><!--do a smart picture watermark function--><?php?>