$ Width = 200; $ Height = 300; $ Img = imagecreatetruecolor ($ width, $ height) or die ("gd image processing not supported "); $ Line_color = imagecolorallocate ($ img, 255,255,255 ); $ Font_type = "c: // windows // fonts // simli. ttf"; // Obtain the truetype font, in which the letter of intent is used // "Journey to the West" with three hexadecimal characters $ Cn_char1 = chr (0xe8). chr (0xa5). chr (0xbf ); $ Cn_char2 = chr (0xe6). chr (0xb8). chr (0xb8 ); $ Cn_char3 = chr (0xe8). chr (0xae). chr (0xb0 ); // 4 hexadecimal characters for "Wu Chengen" $ Cn_str = chr (0xe5 ). chr (0x90 ). chr (0xb4 ). chr (0xe6 ). chr (0x89 ). chr (0xbf ). chr (0xe6 ). chr (0x81 ). chr (0xa9 ); $ Cn_str. = "". chr (0xe8). chr (0x91). chr (0x97 ); Imageline ($ img, 0, 40,200, 40, $ line_color ); Imageline ($ img, 0,260,200,260, $ line_color ); // Display the word "journey to the West" in a vertical bar Imagettftext ($ img, 30, 0, 10, 80, $ line_color, $ font_type, $ cn_char1 ); Imagettftext ($ img, 30, 0, 10,120, $ line_color, $ font_type, $ cn_char2 ); Imagettftext ($ img, 30, 0, 10,160, $ line_color, $ font_type, $ cn_char3 ); // Display the word "Wu Chengen" in the horizontal layout Imagettftext ($ img, 15, 0, 90,254, $ line_color, $ font_type, $ cn_str ); Imagepng ($ img ); Imagedestroy ($ img ); // 6 open an existing image. $ Img = imagecreatefromjpeg ("tower.jpg "); Imagejpeg ($ img ); Imagedestroy ($ img ); // 7. Obtain the attributes of the image. $ Img = imagecreatefromjpeg ("tower.jpg "); $ X = imagesx ($ img ); $ Y = imagesy ($ img ); Echo "the width of image tower.jpg is: <B >x x </B> pixels "; Echo "<br/> "; Echo "<br/> "; Echo "the height of tower.jpg is: <B >$ y </B> pixels "; // Usage of the 8-function getimagesize. $ Img_info = getimagesize ("tower.jpg "); For ($ I = 0; $ I <4; ++ $ I) { Echo $ img_info [$ I]; Echo "<br/> "; } |