<? Php/* param $ image resource param size font size param angle font output angle param showX output position x coordinate param showY output position y coordinate param font file location param content must be in the image displayed content */class showChinaText {var $ text = 'php website programming '; var $ font = 'fonts/simsun. ttc '; // if you do not need to load it to the corresponding directory (local www) var $ angle = 0; var $ size = 15; var $ showX = 100; var $ showY = 160; var $ text0 = 'August 1'; var $ angle0 = 0; var $ showX0 = 230; var $ showY0 = 200; var $ text1 = 'New Lang '; var $ angle1 = 20; var $ showX1 = 135; var $ showY1 = 285; var $ text2 = 'Bride'; var $ angle2 = 20; var $ showX2 = 300; var $ showY2 = 285; var $ text3 = 'shangri-La Hotel, Haidian District, Beijing'; var $ angle3 = 0; var $ showX3 = 120; var $ showY3 = 445; var $ text4 = 'eleven o'clock A.M. '; var $ angle4 = 0; var $ showX4 = 305; var $ showY4 = 480; function showChinaText ($ showText = '') {$ this-> text =! Isset ($ showText )? $ ShowText: $ this-> text; $ this-> show ();} function createText ($ instring) {$ outstring = ""; $ max = strlen ($ instring ); for ($ I = 0; $ I <$ max; $ I ++) {$ h = ord ($ instring [$ I]); if ($ h >=160 & $ I <$ max-1) {$ outstring. = substr ($ instring, $ I, 2); $ I ++;} else {$ outstring. = $ instring [$ I] ;}return $ outstring;} function show () {// output Header Content Header ("Content-type: image/png "); // create an image // $ image = imagecret Ate (400,300); $ image = imagecreatefromjpeg ("01.jpg"); // change the image here to your image path // define the color $ red = ImageColorAllocate ($ image, 255, 0, 0); $ white = ImageColorAllocate ($ image, 255,255,255); $ black = ImageColorAllocate ($ image, 0, 0, 0 ); // fill color // ImageFilledRectangle ($ image, 200,200, $ red); // display text $ txt = $ this-> createText ($ this-> text ); $ txt0 = $ this-> createText ($ this-> text0); $ txt1 = $ this-> createText ($ This-> text1); $ txt2 = $ this-> createText ($ this-> text2); $ txt3 = $ this-> createText ($ this-> text3 ); $ txt4 = $ this-> createText ($ this-> text4); // write the text imagettftext ($ image, $ this-> size, $ this-> angle, $ this-> showX, $ this-> showY, $ white, $ this-> font, $ txt); imagettftext ($ image, $ this-> size, $ this-> angle0, $ this-> showX0, $ this-> showY0, $ white, $ this-> font, $ txt0); imagettftext ($ image, $ this-> size, $ This-> angle1, $ this-> showX1, $ this-> showY1, $ white, $ this-> font, $ txt1); imagettftext ($ image, $ this-> size, $ this-> angle2, $ this-> showX2, $ this-> showY2, $ white, $ this-> font, $ txt2 ); imagettftext ($ image, $ this-> size, $ this-> angle3, $ this-> showX3, $ this-> showY3, $ white, $ this-> font, $ txt3); imagettftext ($ image, $ this-> size, $ this-> angle4, $ this-> showX4, $ this-> showY4, $ white, $ this-> font, $ t Xt4); // ImageString ($ image, 5, 50, 10, $ txt, $ white); // display image imagejpeg ($ image); imagegif ($ image, "a2.jpg"); ImageDestroy ($ image) ;}}?> <? Php // use $ s = new showChinaText ();?>