用imagettftext在图片上输入字符,无法在浏览器中生成图片,该怎么解决
Jun 13, 2016 pm 01:46 PM
button
imagepng
imagettftext
png
用imagettftext在图片上输入字符,无法在浏览器中生成图片
我imagettftext函数在图片上写入汉字字符串,可是却无法在浏览器中输出图片,使用imagepng($im,'x.png');可以将图片输出,但是如果直接输出到浏览器却不行,求高手调教啊。以下我的代码
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php 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,30,30, 0,150, $white,'MSYH.TTF', $button_text); imagepng($im);//使用imagepng($im,'x.png');可以生成x.png,图片也有文字。 imagedestroy($im); ?>
Copy after login
------解决方案--------------------
------解决方案--------------------
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to convert PNG to JPG on Windows 11

How to set button size and color in html

How to rename the extension of all files within a folder, including subfolders

Detailed explanation of PHP chart generation function: chart generation guide for gd library, imagepng, imagestring and other functions
