// Create a canvas. do not have any output or spaces before the canvas is created. Otherwise, the image cannot be generated. $ Im = imagecreatetruecolor (100,10 ); // $ Cc = imagecolorallocate ($ im, 245,245,245 ); // Imagefill ($ im, 0, 0, $ cc ); // Color, in RGB format $ Red = imagecolorallocate ($ im, 245 ); $ Cc = imagecolorallocate ($ im, 245,245,245 ); // Color $ Red1 = imagecolorallocate ($ im, 30,144,255 ); $ Red2 = imagecolorallocate ($ im, 220,20, 60 ); $ Red3 = imagecolorallocate ($ im, 0,206,209 ); $ Red4 = imagecolorallocate ($ im, 255,255, 0 ); // The color of the filled rectangle can be customized. The color defined above is just a test example here. the length ratio can be controlled based on the project's dynamic data. // Circle // Imageellipse ($ im, 20, 20, 20, $ red ); // Straight line // Imageline ($ im, 0, 0, 400,300, $ red ); // Rectangle // Imagerectangle ($ im, $ red ); // Fill the rectangle Imagefilledrectangle ($ im, 0, 0, 30, 10, $ red ); Imagefilledrectangle ($ im, 30,0, 100,10, $ cc ); // Arc // Imagearc ($ im, 100,100, 50, 50, 180,270, $ red ); // Slice // Imagefilledarc ($ im, 100,100, 180,270, $ red, IMG_ARC_PIE ); // Copy the image to the canvas // 1. load the source image // $ SrcImage = imagecreatefromgif ("2.GIF "); // Here we can use a getimagesize () // $ SrcImageInfo = getimagesize ("2.GIF "); // Copy the source image to the target canvas // Imagecopy ($ im, $ srcImage, 0, 0, 0, $ srcImageInfo [0], $ srcImageInfo [1]); Header ("content-type: image/png "); // Generate an image Imagepng ($ im ); // Release the memory! If this sentence is not added, apache will crash if the traffic is high. Imagedestory ($ im ); ?> |