Images); you can output images, but if you can directly output images to a browser, you cannot. The following is my code & lt ;? PhpHeader (Content-type: & nbsp; imag uses imagettftext to input characters on the image, and the image cannot be generated in the browser.
I wrote a Chinese character string in imagettftext.pdf on the image, which can be used to output the image in a browser and use imagepng(imim,'x.png '). I can output the image but cannot output it to a browser. My code below
Header ('content-type: image/png ');
Putenv ('gdfontpath = C: \ WINDOWS \ fonts ');
$ Button_text = 'Button ';
$ Button_text = $ button_text.rand (30, 50 );
$ Im = imagecreatetruecolor (400,200 );
$ Black = imagecolorallocate ($ im, 0, 0, 0 );
$ White = imagecolorallocate ($ im, 255,255,255 );
Imagefill ($ im, 0, 0, $ black );
Imagettftext ($ im, 0,150, $ white, 'msyh. ttf', $ button_text );
Imagepng ($ im); // use imagepng(immediate im,'x.png' to generate X.png. The image also contains text.
Imagedestroy ($ im );
?>
------ Solution --------------------
Reference:
Reference:
Reference:
There is no error message. the browser is blank, but some garbled characters will appear in IE browser. I try to replace imagettftext with imagestring to make the output work normally, provided that I want to remove Chinese characters ......
Imagestring does not support Chinese characters. Only yong imagettftext is supported. if it is garbled, it indicates that the image may be lost before it is generated ......
There are two UTF-8 formats: one is UTF-8 without bom, and the other is changed from bom header to bom header without bom header.
------ Solution --------------------
Reference:
Text.
This is only because your program file has a BOM header. Just remove it.