Tuesday, March 27, 2018

Example of GD Library to Draw Smiley Face using PHP


--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD - IT)
Contact No : 7600044051
E-Mail : rupareleducation@gmail.com

Example of GD Library to Draw Smiley Face 


<?php
     // create a 200*200 image
     $img imagecreatetruecolor(200200);

     // allocate some colors
     $white imagecolorallocate($img255255255);
     $red   imagecolorallocate($img255,   0,   0);
     $green imagecolorallocate($img,   0255,   0);
     $blue  imagecolorallocate($img,   0,   0255);

     // draw the head
     imagearc($img100100200200,  0360$white);
     // mouth
     imagearc($img10010015015025155$red);
     // left and then the right eye
     imagearc($img,  60,  75,  50,  50,  0360$green);
     imagearc($img140,  75,  50,  50,  0360$blue);

     // output image in the browser
     header("Content-type: image/png");
     imagepng($img);

     // free memory
     imagedestroy($img);

?>
The above example will output something similar to